I have set “Access-Control-Allow-Origin”: “*” in the header still i am getting No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Sample CODE : import ok from ‘wix-http-functions’; export function post_sampleAPICall(request) { let options = { “headers”: { “Access-Control-Allow-Origin”: "",* “Content-Type”: “application/json” }, “body”: { “content”: “hello from API” } }; return ok(options); }
Certain CORS (Cross-Origin Resource Sharing) requests are restricted when originating from a browser. Usually, GET requests and certain POST requests can be made from your site’s Public , Page , or Site code. All other requests need to be made from your site’s Backend code. Invalid requests will cause an error that you can see using your browser’s developer tools . If you are experiencing an issue with a fetch call due to a CORS restriction, move the call to the backend as described below.