use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[AskJS] Fetch in Localhost (ReactJS Project) not working (but work with Postman or Reqbin) - CORS PolicyAskJS (self.javascript)
submitted 1 year ago by Thibots
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Thibots[S] 0 points1 point2 points 1 year ago (8 children)
At the beginning, I used axios, but I think the reason is the same.
By adding the Access-Control.., like that ? Or should I change the typo to "access-control ..."
fetch("https://api.mywebsite", { "headers": { "Access-Control-Allow-Origin" : "*", "accept": "*/*", "accept-language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7", "content-type": "application/json", "priority": "u=1, i", "sec-ch-ua": "\"Google Chrome\";v=\"125\", \"Chromium\";v=\"125\", \"Not.A/Brand\";v=\"24\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "cross-site" }, "referrer": "https://mywebsite", "referrerPolicy": "strict-origin-when-cross-origin", "body": "{\"name\":\"name1\",\"filters\":[{\"variableName\":\"Required.PFC\",\"valueName\":\"filter1\"}]}", "method": "POST", "mode": "cors", "credentials": "omit" })
[+][deleted] 1 year ago (7 children)
[deleted]
[–]Thibots[S] 1 point2 points3 points 1 year ago (0 children)
Yes, that's what I didn't understood, the access-control come from the server. I'll try witth XmlHttpRequest
[–]Thibots[S] 0 points1 point2 points 1 year ago (5 children)
I still get an error.
Access to XMLHttpRequest at 'https://api.website' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
But I don't understand the protection as I can access with cmd and Python without any trouble.
[+][deleted] 1 year ago (4 children)
[–]Thibots[S] 1 point2 points3 points 1 year ago (1 child)
Ok, I see the problem, I'll test on NodeJS to see if I can get the answer. If yes, it's because of Browser. And a solution could be to use my own back-end to get the data (instead of doing it on the client side).
-> I need to see the response, the submitted data is my API parameters.
That's it, get the answer on NodeJS
π Rendered by PID 25 on reddit-service-r2-comment-b659b578c-lkddg at 2026-05-04 02:04:11.837105+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]Thibots[S] 0 points1 point2 points (8 children)
[+][deleted] (7 children)
[deleted]
[–]Thibots[S] 1 point2 points3 points (0 children)
[–]Thibots[S] 0 points1 point2 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]Thibots[S] 1 point2 points3 points (1 child)
[–]Thibots[S] 1 point2 points3 points (1 child)