#has been blocked by CORS policy No 'Access-Control-Allow-Origin' header is present on the requested

17 messages · Page 1 of 1 (latest)

jagged vigil
#

error

#

has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

#

let response_backend = await fetch(`mybackend`, { method: "GET"} ); let json_back = await response_backend.json();

thin oak
#

https://www.npmjs.com/package/cors
You need you allow your front end specifically or set a proxy so the domains match

#

#❓javascript message This post explained it well

jagged vigil
#

cuz this request works fine in python but not js from the same frontend

thin oak
#

Is your python request running in the browser?

jagged vigil
thin oak
#

Then it is not the same origin

#

ASsuming your JS is

jagged vigil
#

im using python for webserver/backend (specifically sanic) , html and js for the website

#

do i make my python server respond with the header Access-Control-Allow-Origin with the ip of my website or? im really confused

thin oak
#

Im not really familiar with python servers but they likely have some sort of cors library. But yeah you need to either allow the ip of your website, or get the ips to be the same

jagged vigil
#

oh alr ill see if i can find anything in sanics docs

#

THanks