Skip to content
Back

CORS + 401 Error with Appwrite Authentication

  • 0
  • Auth
  • Web
Toan Nguyen
20 Oct, 2025, 09:28

⁠I'm getting a CORS + 401 Error with Appwrite Authentication

Access to fetch at 'https://cloud.appwrite.io/v1/account/sessions/email' from origin 'https://my-custom-subdomain.appwrite.network' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. POST https://cloud.appwrite.io/v1/account/sessions/email net::ERR_FAILED 401 (Unauthorized)

Framework: Next.js 14 with Appwrite SDK Authentication: Email/Password using account.createEmailPasswordSession() Environment Variables: NEXT_PUBLIC_APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1 NEXT_PUBLIC_APPWRITE_PROJECT_ID=my-project-id

My Integrations > Platforms

TypeScript
Name|Platform type|Identifier|Last updated
My Project Name|Web|my-custom-subdomain.appwrite.network|3 days ago
localhost|Web|—|A few seconds ago

It works well in localhost.

What I've tried

https://appwrite.io/blog/post/cors-error

So, how to fix it?

TL;DR
Developers are encountering a CORS + 401 error with Appwrite Authentication while using Next.js 14 and the Appwrite SDK. The error is due to a missing 'Access-Control-Allow-Origin' header, causing the request to be blocked. The solution involves enabling CORS for the specific origin in the Appwrite console under "Integrations > Platforms." This should resolve the issue and allow the request to go through successfully.
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