datocms / plugins

Repository providing samples using the Plugins SDK
MIT License
33 stars 47 forks source link

Changed content-type from application/json to text/plain #76

Closed MohamedElshazly closed 1 year ago

MohamedElshazly commented 1 year ago

Changed the content type to text/plain to transform the request into a simple request and avoid firing a preflight.

Reason for that was that in sveltekit the preflight needed to have a 200 ok status, and sveltekit doesn't allow you to intercept or see OPTIONS requests so I couldn't pass the preflight.

stefanoverna commented 1 year ago

Seems like a limitation of sveltekit.. and we cannot change the content type to text/plain because 1) it's wrong 😄 and 2) it would break all existing webhooks which expect an application/json 😕

MohamedElshazly commented 1 year ago

Yea I figured, locally it fixed everything for me and I parsed the request correctly on my end. So I was wondering if we could accommodate both somehow or have it as an option? I will try to work on a way and see if it would be possible