Next.js Discord

Discord Forum

Next.JS Cors Error When calling api from fetch

Unanswered
Scaly-naped Pigeon posted this in #help-forum
Open in Discord
Scaly-naped PigeonOP
please I need help , i am using a payment gateway and it was working on react but when i switched to next js it stopped working , and i always get this error

Access to fetch at 'https://api.payment/session' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I am using fetch on the front end something like this : await fetch('https://api.payment/session', {

0 Replies