Back

[SOLVED] how to connect to cloud endpoint?

  • 0
  • Web
  • Cloud
Binyamin
19 May, 2023, 12:49

localhost is accepted by default as Meldiron said here https://discord.com/channels/564160730845151244/1106531116317417564/1108048851690078279 Are you accessing your website using localhost or 127.0.0.1 ? it solved the problem in my previous case.

TL;DR
The user was having trouble connecting to a cloud endpoint and received a CORS error. They discovered that the issue was a mistake in the project ID. After verifying the correct project ID and ensuring it was being sent as a header in the request, the issue was resolved. There was some confusion about multiple requests in the network tab and a potential CORS problem, but it was determined that changing the value in `Access-Control-Allow-Origin` to `*` may solve the issue. There was also a discussion about using `localhost` as a domain in Appwrite Cloud, with the recommendation to use the computer's IP instead.
D5
19 May, 2023, 13:34

If it's appwrite cloud, why did you have or want to setup it as localhost?

Binyamin
19 May, 2023, 13:35

I think its for local web development

D5
19 May, 2023, 13:47

At least with the cloud tag it makes me think the user is trying to setup localhost as a domain the the appwrite Cloud console or locally. You can make that locally, however it will not work in your app, since it's needed to setup the computer's IP as domain as you said

manazo
19 May, 2023, 14:48
manazo
19 May, 2023, 14:50

I'm trying this from localhost. I'm making the request from a Client Component in NextJS. is it causing anything?

Binyamin
19 May, 2023, 14:52

Interesting Can you change this to * and retry?

manazo
19 May, 2023, 14:54

still getting the same error

Binyamin
19 May, 2023, 15:02

In your network tab what value you have in Access-Control-Allow-Origin:

manazo
19 May, 2023, 15:09

i also have the same

Binyamin
19 May, 2023, 15:10

So, It's not a cors problem,

Binyamin
19 May, 2023, 15:10

Everything else in the api calls is in order?

safwan
19 May, 2023, 15:12

@manazo this is weird lol. could you share the code wherre you're making a request to Appwrite from your client component?

safwan
19 May, 2023, 15:13

i see 3 requests to account. are all of them the same request?

manazo
19 May, 2023, 15:14

here's the code. I don't find any issues in the code. and if it's not a cors problem, why I'm seeing a cors error in the console?

safwan
19 May, 2023, 15:15

can you also share the code in appwrite-config? looks like a custom component

manazo
19 May, 2023, 15:17

when I do one request, it shows 3 logs in Network. I'm not sure why it's happening. I've confirmed my function is getting called only once by a consol.log()

Binyamin
19 May, 2023, 15:18

What is the content in the preview tab for the first 404 request?

manazo
19 May, 2023, 15:19

not a custom component. I'm just exporting everything related to appwrite for better dev experience

manazo
19 May, 2023, 15:20

says failed to load

Binyamin
19 May, 2023, 15:20

What could happened is when the value of the project is not the exact one, then in this use-case Appwrite will return 404, can you verify that it is the correct one? and that it's actually being send as header in the request?

manazo
19 May, 2023, 15:25

i really should rethink my career choice. i was working with a paste mistake in the project id all this time

Binyamin
19 May, 2023, 15:25

Happens to anyone

manazo
19 May, 2023, 15:28

thanks to both @Binyamin & @safwan. you guys really helped

manazo
19 May, 2023, 15:29

[SOLVED] how to connect to cloud endpoint?

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