Prerequisites
Issue
Hey Guys,
I have installed and used the fastify cors module in my eCom project and it's working as expected but when i implemented payment gateways in the code, I ran into a issue. I have implemented 2 PGs and after the payment is completed on the PG's page they redirect users to my backend with some data about the payment.
When they redirect the users to the backend it is getting blocked by the cors. I've tried adding my endpoints for these PG in my cors whitelist but to no avail. The reason being that these redirects are server to server and there is no origin attached to these requests.
So when i try to add these endpoints to my whitelist cors is trying yo match these from the origin which is either null or undefined.
Since the cors module doesn't have access to the complete request object, I can't match it with the headers or the query or any number of things from the request object to skip cors for these routes and I'm blocked because of this.
I tried skipping cors from these routes like this also
await fastify.register(paymentRoutes, {cors: false}, { prefix: "/api" });
But this is also not working.
Can you suggest how should i go about this issue.
Prerequisites
Issue
Hey Guys,
I have installed and used the fastify cors module in my eCom project and it's working as expected but when i implemented payment gateways in the code, I ran into a issue. I have implemented 2 PGs and after the payment is completed on the PG's page they redirect users to my backend with some data about the payment.
When they redirect the users to the backend it is getting blocked by the cors. I've tried adding my endpoints for these PG in my cors whitelist but to no avail. The reason being that these redirects are server to server and there is no origin attached to these requests.
So when i try to add these endpoints to my whitelist cors is trying yo match these from the origin which is either null or undefined.
Since the cors module doesn't have access to the complete request object, I can't match it with the headers or the query or any number of things from the request object to skip cors for these routes and I'm blocked because of this.
I tried skipping cors from these routes like this also
await fastify.register(paymentRoutes, {cors: false}, { prefix: "/api" });But this is also not working.
Can you suggest how should i go about this issue.