I’m having a problem to POST the form data caused by error 400 strict-origin-when-cross-origin
at postFormDataAsJson
at async HTMLFormElement.handleFormSubmit
In my header I have this:
access-control-allow-credentials: true
access-control-allow-origin: null
This is the POST method that I am using:
https://simonplend.com/how-to-use-fetch-to-post-form-data-as-json-to-your-api/
Please help!
Source: Ask Javascript Questions
One Reply to “Form POST error 400 strict-origin-when-cross-origin”
Hi there,
I wrote the blog post that you’ve linked to 🙂
The access-control-allow-origin header you are sending back must always have a value, otherwise it effectively disables any cross-origin requests, which I think is causing the problem that you are seeing.
I’ve written an article about how to configure CORS which might help you: https://simonplend.com/how-to-fix-those-confusing-cors-errors-when-calling-your-express-api/.
I also find this tool very useful for figuring out the correct CORS headers to send: https://httptoolkit.tech/will-it-cors/
Let me know how you get on!
Thanks,
SImon