Back

[SOLVED] Just moved app to netlify and I'm getting CORS issue please help

  • 0
  • Web
Triptych
16 Sep, 2023, 23:35

I just moved my app to netlify hosting ( from replit ) and now I cannot even seem to get basic things working - when I try to access my api I get a CORS error:


Access to XMLHttpRequest at 'https://appwrite.denweaver.com/v1/account' from origin 'https://denweaver.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Does anyone have any insights on what I might be doing wrong?

The app is based on astro3 --- it was all working before :/

TL;DR
Summary: The user recently moved their app from Replit to Netlify and is now experiencing a CORS (Cross-Origin Resource Sharing) issue. They suspect it might be related to missing environment variables or a configuration error. They have tried manually setting the PROJECT_ID and that resolved the CORS issue. They also mention adding Vercel as a web platform in Appwrite. They have updated their astro.config.mjs file but don't believe it's the cause of the issue. They are seeking insights or suggestions on what they might be doing wrong. Solution: The user resolved the issue by manually setting the PROJECT_ID, which fixed the CORS problem.
Triptych
16 Sep, 2023, 23:36

I did update my astro.config.mjs but I don't think this has anything to with the requested resource .. it's just for things asked for on my site I assume server: { headers: { "Access-Control-Allow-Origin": "*", }, },

Triptych
16 Sep, 2023, 23:39

I also have a CNAME set on DNS to route api calls through my domain

Drake
16 Sep, 2023, 23:43

Did you add vercel as a web platform in Appwrite?

https://appwrite.io/docs/getting-started-for-web#addPlatform

Triptych
16 Sep, 2023, 23:54

somehow I'm getting things to work, it seems like this is a side effect of not sending the right PROJECT_ID -- because my env variables are not working . let me keep snooping and see if fixing that works

Drake
16 Sep, 2023, 23:55

That was going to be my next suggestion 😅

Triptych
16 Sep, 2023, 23:56

when I set PROJECT_ID manually it's "working " -- no CORS issue. I'll see if I can fix that

Triptych
17 Sep, 2023, 00:10

yes, issue solved - it was missing .env data so the client call was failing - the CORS issue was a ... red herring?

D5
17 Sep, 2023, 00:13

Seems yes

D5
17 Sep, 2023, 00:14

[SOLVED] Just moved app to netlify and I'm getting CORS issue please help

Drake
17 Sep, 2023, 01:34

You're not putting a .env file in your repo are you?

Triptych
18 Sep, 2023, 21:24

no, that's why I didn't transfer, I'm adding the variables via Netlify's UI

Triptych
18 Sep, 2023, 21:24

It's working now

Triptych
18 Sep, 2023, 21:27

Thank you @Steven for your fast response - it really gives me confidence that you all are really committed to helping us use your service. I'm going all in with my site on appwrite

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