Back

[SOLVED] CORS request did not succeed

  • 0
  • Web
Berserker
28 Mar, 2023, 19:03

I tried to follow almost every tutorials available online to solve this error but those all didn't work along with it even javascript AppwriteException: Network request failed even this error is printed in the console

TL;DR
There was an issue with CORS (Cross-Origin Resource Sharing) requests. The user was advised to try prefixing the environment variable with `NEXT_PUBLIC_`. Additionally, they were reminded to rebuild the app after adding the ENV variables. The user found that the error was caused by directly setting the endpoint and project ID as strings instead of importing them from the .env file. The solution was to properly set the endpoint and project ID using the `Client`.
Berserker
28 Mar, 2023, 19:04
joeyouss
28 Mar, 2023, 19:18

can you send all the browser console logs?

Berserker
29 Mar, 2023, 03:16
TypeScript

AppwriteException: Network request failed
    AppwriteException sdk.js:76
    call sdk.js:398
    rejected sdk.js:23
    promise callback*step sdk.js:24
    __awaiter sdk.js:25
    __awaiter sdk.js:21
    call sdk.js:335
    create sdk.js:469
    __awaiter sdk.js:25
    __awaiter sdk.js:21
    create sdk.js:444
    signUpUser Signup.jsx:33
    React 23
    renderReactElement index.js:346
    doRender index.js:489
    _render index.js:507
    asyncGeneratorStep _async_to_generator.js:13
    _next _async_to_generator.js:31
    _asyncToGenerator _async_to_generator.js:36
    _asyncToGenerator _async_to_generator.js:28
    _render index.js:525
    render index.js:498
    _hydrate index.js:639
    asyncGeneratorStep _async_to_generator.js:13
    _next _async_to_generator.js:31
    promise callback*asyncGeneratorStep _async_to_generator.js:22
    _next _async_to_generator.js:31
    promise callback*asyncGeneratorStep _async_to_generator.js:22
    _next _async_to_generator.js:31
    promise callback*asyncGeneratorStep _async_to_generator.js:22
    _next _async_to_generator.js:31
    promise callback*asyncGeneratorStep _async_to_generator.js:22
    _next _async_to_generator.js:31
    _asyncToGenerator _async_to_generator.js:36
    _asyncToGenerator _async_to_generator.js:28
    _hydrate index.js:641
    hydrate index.js:528
    <anonymous> next-dev.js:40
    promise callback* next-dev.js:35
    NextJS 7```
safwan
29 Mar, 2023, 07:55

@Berserker where is your client init?

safwan
29 Mar, 2023, 07:56

you created an instance of Client called client, but you are not setting the endpoint, projectid

Berserker
29 Mar, 2023, 08:16

@safwan again thnx bro lemme try it out

Berserker
29 Mar, 2023, 08:35

@safwan javascript client.setEndpoint(process.env.END_PT).setProject(process.env.PROJECT_ID); this code is causing the above error

Berserker
29 Mar, 2023, 08:36

@safwan whereas setting the endpoint and project id **as string ** directly , rather than importing them from the .env file is not causing any error

safwan
29 Mar, 2023, 09:10

that seems like a problem with the ENV variables then.

Are you setting the ENV variables like so?

TypeScript
END_PT=https://your-domain.com/v1
safwan
29 Mar, 2023, 09:11

Sometimes people store ENV variables in double quotes, which can be an issue

safwan
29 Mar, 2023, 09:11

Another thing to check, is if you're rebuilding the app after adding the ENV variables?

Berserker
29 Mar, 2023, 10:56

Nope

Berserker
29 Mar, 2023, 10:56

Yes bro i didn't use double quotes

Berserker
29 Mar, 2023, 10:57

@safwan lemme try that out bro

safwan
29 Mar, 2023, 10:57

yep try rebuilding the app

Berserker
29 Mar, 2023, 15:39

I did that for more than 3 times as of now 😭

Drake
29 Mar, 2023, 17:46

you're using nextjs 13?

Berserker
29 Mar, 2023, 18:03

@Steven yes

Drake
29 Mar, 2023, 18:04
Berserker
29 Mar, 2023, 18:05

@Steven okie

Berserker
30 Mar, 2023, 08:08

@Steven it worked thank u

Drake
30 Mar, 2023, 13:37

[SOLVED] CORS - request did not succeed

Drake
30 Mar, 2023, 13:37

[SOLVED] CORS request did not succeed

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