$fetch with POST and same origin policy error

Hi everyone, I'm trying to make a POST request with $fetch to my backend(asp.net) but I consistently get this error message. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:myport/myendpoint. (Reason: header ‘content-type’ is not allowed according to header ‘Access-Control-Allow-Headers’ from CORS preflight response). GET requests to my backend works. My backend CORS set up also should be permitting that the frontend makes this request. I wonder if my frontend being http:localhost:port/etc... and my backend being https:localhost:someport/etc has something to do with it but idk. Here's my function: async makeRes(){ const h = useRequestHeaders(['']) return await $fetch('https://localhost:port/myendpoint',{ headers:{ h }, method: 'POST', body:{ 'message': <my-data>, } }) } Whats yalls opinion?
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
clownshark5503
clownshark5503OP2y ago
You were right, I went over the documentation for CORS in aspnet and now I'm getting a 400 error instead when I make a POST request. Thank you!
Want results from more Discord servers?
Add your server