Next.js Discord

Discord Forum

Getting an error when fetching data using an API endpoint

Unanswered
Dwarf Crocodile posted this in #help-forum
Open in Discord
Dwarf CrocodileOP
Hey, so earlier I was putting my AWS keys in frontend and was doing the data fetching from S3 on frontend.
But I have moved this to backend now. I have kept the processing and parsing of response on frontend though.
All of my API endpoints are working, but just 1 API is not working and I can not find the issue.

I have put the issue/pics here: 👇https://docs.google.com/document/d/1_FZKNGSbhy7YqWPSegMRekec4Xey9LNJyyx4cpvN888/edit?usp=sharing

7 Replies

Spectacled bear
You need to enable cors from the backend.
@Spectacled bear You need to enable cors from the backend.
Dwarf CrocodileOP
I have enabled the CORS bhai
i have added:

CORS(app,origins=["http://localhost:3000","http://localhost:3000/"])


My fontend is on 3000 and backend is on 5000
@Dwarf Crocodile i have added: CORS(app,origins=["http://localhost:3000","http://localhost:3000/"]) My fontend is on 3000 and backend is on 5000
Miniature Pinscher
Set CORS to * for development environments. You can't set CORS headers to localhost.
@Miniature Pinscher Set CORS to `*` for development environments. You can't set CORS headers to localhost.
Dwarf CrocodileOP
Actually, my other API endpoints are working fine
just this one is giving me CORS error
@Miniature Pinscher Set CORS to `*` for development environments. You can't set CORS headers to localhost.
Dwarf CrocodileOP
I did:
CORS(app,origins="*")

Still getting the same error.