3 ms·
> I wish there was a way to let me make POST requests on behalf of the user without dealing with CORS. Of course the request wouldn't include any user cookies e
by jaffathecake 5y ago
> I wish there was a way to let me make POST requests on behalf of the user without dealing with CORS. Of course the request wouldn't include any user cookies etc to avoid the security issues.
You can! And it can include credentials!
You can do this with a basic <form> element, so fetch() lets you do the same. What you can't do is read the response.
Demo: https://jakearchibald.com/2021/cors/playground/?prefillForm=1&requestMethod=POST&requestUseCORS=&requestSendCredentials=1&preflightStatus=406&preflightAllowOrigin=&preflightAllowCredentials=&preflightAllowMethods=&preflightAllowHeaders=&responseAllowOrigin=&responseAllowCredentials=&responseExposeHeaders=&requestHeaderName=Content-Type&requestHeaderValue=multipart%2Fform-data https://jakearchibald.com/2021/cors/playground/?prefillForm=...
- Aulig 5y agoThank you! Unfortunately I need to read the response (so extra thank you for pointing that out before), but maybe just posting will be enough for a future application :)