GhostOperator
05/27/2023, 11:04 PMCORS
) when attempting to access my API from a locally running Next.js app. The API itself is forwarded through Zero Trust Cloudflare Tunneling. I would greatly appreciate any help to solve this issue.
Here's the scenario:
- I have a Next.js app running on my local machine, which needs to communicate with my API.
- Whenever I make requests to the API using the Fetch API within my Next.js app, the network tab in the browser displays a "PreflightMissingAllowOriginHeader" error related to CORS.
- Interestingly, I don't encounter any CORS errors when testing the API using tools like Postman.
Key details about my setup:
- The Next.js app is running locally, not hosted via Cloudflare.
- The API server is separate and is forwarded through Zero Trust Cloudflare Tunneling.
Despite these measures, I'm still experiencing the CORS error when attempting to access the API from my Next.js app.
I suspect there may be some configuration aspect related to Cloudflare or the way Zero Trust Cloudflare Tunneling handles incoming requests that I'm overlooking. I would be grateful for any suggestions, troubleshooting steps, or guidance on resolving this issue. I'm also down for providing any details if needed.
https://cdn.discordapp.com/attachments/1112154295001944174/1112154541966758059/image.png▾
https://cdn.discordapp.com/attachments/1112154295001944174/1112154542260363404/image.png▾
kian
05/27/2023, 11:05 PMkian
05/27/2023, 11:05 PMGhostOperator
05/27/2023, 11:05 PMGhostOperator
05/27/2023, 11:06 PMkian
05/27/2023, 11:06 PMkian
05/27/2023, 11:06 PMGhostOperator
05/27/2023, 11:06 PMkian
05/27/2023, 11:06 PMGET
, it'll refuse to make the request.kian
05/27/2023, 11:06 PMOPTIONS
'preflight' which says "I plan to do this method with these headers, is that okay?" and your app will respond "Here's what I accept"kian
05/27/2023, 11:07 PM<METHOD>
requestkian
05/27/2023, 11:07 PMGhostOperator
05/27/2023, 11:08 PMGhostOperator
05/27/2023, 11:13 PM