#[SOLVED] Appwrite Cors Errors after domain added

41 messages · Page 1 of 1 (latest)

austere rose
#

So I'm working on an app for my company and I've added in my domain name as the hostname for the project as well as for the custom domain.

But I'm still getting CORS Errors saying that:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cloud.appwrite.io/v1/databases/test-domain/collections/questions-collection/documents. (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘https://localhost’).

When I have not even added localhost as my hostname I've added in my project domain name

austere rose
#

@simple forge Hey man thought maybe you could help me out a bit with this

simple forge
#

Have you added that domain as a platform in the console UI?

#

with what you have I don't think it will pass the validation though xn--localhost-ob0e

austere rose
#

I've added it as the hostname in the project setup

#

And I've added a sub-domain of my main domain in the custom domains section of my project. So settings

#

Here are a couple of screen shots of what I'm talking about

#

@simple forge That is all I have configured and added nothing else

junior arrow
austere rose
#

I see I've checked all my environment variables in Vercel my hosting platform. They are set to the same values that I'm using in development which work perfectly.

@junior arrow I'm not sure where or how I would use this ('use the custom domain, you'll need to use it when calling setEndpoint()'). Is it in my appwrite.js file? So do I add it into this code instead of the default appwrite endpoint?


client.setEndpoint("https://cloud.appwrite.io/v1")
.setProject(projectID); ```
#

So add this in instead then?


client.setEndpoint("api.dyslexiaquiz.com")
.setProject(projectID); ```
junior arrow
austere rose
#

I cannot configure the full domain name in my custom domains in my appwrite project because then I would have to add an A Record or CNAME record which would cause a conflict with my current CNAME record for the hosting platform on my root domain

#

Might it be because I'm using the sub-domain because it won't let my access the site using that due to a lack of security certificates

junior arrow
#

Maybe you have extra spaces or you're missing the https

junior arrow
austere rose
#

Hi sorry it was 3am and I wasn't feeling too well. I added in the endpoint correctly. But I'm still getting the same CORS error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.dyslexiaquiz.com/v1/databases/test-domain/collections/questions-collection/documents. (Reason: CORS request did not succeed). Status code: (null).
2
❌ QuizContext: Error fetching questions: AppwriteException: Network request failed
NextJS 3
69-399726193d546630.js:1:3771
NextJS 2
Full error details:
Object { name: "AppwriteException", message: "Network request failed", stack: "R@https://www.dyslexiaquiz.com/_next/static/chunks/424-c3a48901ba821283.js:1:12528\n2180/call/<@https://www.dyslexiaquiz.com/_next/static/chunks/424-c3a48901ba821283.js:1:14855\ns@https://www.dyslexiaquiz.com/_next/static/chunks/424-c3a48901ba821283.js:1:10655\n" }

message: "Network request failed"

name: "AppwriteException"

stack: "R@https://www.dyslexiaquiz.com/_next/static/chunks/424-c3a48901ba821283.js:1:12528\n2180/call/<@https://www.dyslexiaquiz.com/_next/static/chunks/424-c3a48901ba821283.js:1:14855\ns@https://www.dyslexiaquiz.com/_next/static/chunks/424-c3a48901ba821283.js:1:10655\n"

<prototype>: Object { … }

#

I've checked my Environment Variables and they are all correct. I just don't know what could be causing this as everything else seems to check out

junior arrow
austere rose
#

A few days ago and I've checked with the namecheap DNS team that they have said that all the records have propagated perfectly. The sub-domain is also working on appwrite it says it's all verified

half spire
#

seems like the problem is with the SSL: I'm seeing the error: `Requested host does not match any Subject Alternative Names (SANs) on TLS certificate [3d45f294eb3f84a3350132a205bbb99015c50260b9e9f16124d9b6468fd655d6] in use with this connection.

Visit https://www.fastly.com/documentation/guides/concepts/errors/#routing-errors for more information.`

visiting the URL: https://api.dyslexiaquiz.com/v1

junior arrow
#

No need to change anything in your DNS provideder

austere rose
junior arrow
austere rose
#

Hey @junior arrow so I've removed the custom domain and added it again but I'm still getting the cors errors. Maybe it's a silly question but could this be because I'm using a sub-domain of my main domain setup in Namecheap DNS management. And I thought this might be relevant as well should I maybe change it to my custom domain?

#

It's currently just set to Appwrite and it probably should be if I want to retrieve records from the Database

#

Do you think that generating some new API keys for the whole project might help too

junior arrow
#

If you look at the network logs for your app, you'll see there's a 401 error. It's unable to retrieve the data from the collection. The permissions on your collection may need to be tweaked

austere rose
#

Hey @junior arrow thanks for all the help so far. I've been unwell so it's really helped out a lot. I've fixed the 401 error now but I'm still getting the CORS error and this is what it says on the network tab ''access-control-allow-origin
https://localhost'',
Is there any way I can edit this so that dyslexiaquiz.com is part of my allowed origin?

I've checked in the api platform and I have dyslexiaquiz.com as my hostname. Is there a way I could maybe use the API to query the database instead as a workaround?

junior arrow
austere rose
#

Hey @junior arrow thank you so much!! That's fixed my issue. It's all working perfectly now. You've had so much patience and you've really saved my hide. Sorry for all the mishaps it's been a tough time. I hope you've had a great weekend 🙂