Skip to content
Back

Netlify CORS issue

  • 0
  • Web
  • Cloud
pagecarbajal
3 Mar, 2025, 06:57

#🗂│web

Hello guys, I need a little bit of help.

I already read the article: https://appwrite.io/blog/post/cors-error

My app has 2 web platforms with the following hosts:

  • myfrontend.local
  • vuela-plus.netlify.app

My original platform was set for localhost, but I changed it to myfrontend.local to try fixing my CORS issue. I hardcoded a local IP to the domain myfrontend.local using my hosts file. This works - local development has no CORS issues.

My issue is on Netlify

I set my env variables as:

NEXT_PUBLIC_APP_URL=httpa://vuela-plus.netlify.app

My Netlify Platform is configured for the correct domain, yet I still get this error:

Access to fetch at 'https://cloud.appwrite.io/v1/account/sessions/email' from origin 'https://vuela-plus.netlify.app' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://localhost' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Could this be a Netlify-specific issue?

Can anyone help?

TL;DR
Developers facing CORS issue on Netlify while trying to make a fetch call to an external API. They've set up env variables correctly and configured the Netlify platform for the domain, but the error persists. The CORS error seems to originate from the 'Access-Control-Allow-Origin' header. The discrepancy between the expected origin and the actual origin of the header is causing the issue. Solution: Configure the 'Access-Control-Allow-Origin' header on the server to allow requests from the specified domain. Update the header value to match the domain making the requests. This should resolve the CORS error on Netlify.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more