Back

Network request failed

  • 1
  • Self Hosted
  • Web
f4ls3
5 Nov, 2024, 23:51

So I've swapped from hard-coded variables with my self-hosted instance endpoint for example to env variables as I wanted to deploy to prod. After doing this suddenly I can still reach my login page but cant login with essentially two errors in the browser console and none in my container:

TypeScript
Access to XMLHttpRequest at 'https://appwrite.roehrdanz.cloud/v1/account/sessions/email' from origin 'https://webtool.roehrdanz.cloud' 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.

and

TypeScript
Uncaught (in promise) AppwriteException: Network request failed
    at c.<anonymous> (https://webtool.roehrdanz.cloud/_next/static/chunks/658-aeff67198c3f381b.js:1:15174)
    at Generator.throw (<anonymous>)
    at a (https://webtool.roehrdanz.cloud/_next/static/chunks/658-aeff67198c3f381b.js:1:8601)

This probably isnt related to my env variables because when testing locally they work flawlessly. I've also moved to a bare-metal server. This server is proxmox virtualized and is running 2 VMs: one with appwrite and another with some deployments including this nextJS webapp. Is there maybe something configured wrongly in the nextjs container?

TL;DR
Developers switched from hard-coded variables to environment variables for a production deployment. Now facing CORS policy and network request failed errors when trying to login. Local testing with environment variables works fine. Issue may be related to CORS configuration in the Next.js container. Fix the Access-Control-Allow-Origin header to match the origin.
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