pofider / node-simple-odata-server

Simple OData server for node.js
MIT License
97 stars 60 forks source link

Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response. #31

Closed kapusadam closed 6 years ago

kapusadam commented 6 years ago

Hi guys!

Please correct me if i am wrong, but had this issue, that i get back this error: Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response.

I set the odataServer.cors('') , and as i can see in my preflight call in the response header i get it back nicely: access-control-allow-origin : but shouldn't this also bee sent with not just the options call?

https://mdn.mozillademos.org/files/14289/prelight.png -> this is from https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Preflighted_requests

kapusadam commented 6 years ago

@pofider any thoughts on this?

pofider commented 6 years ago

Yes, it seems you are right. Don't you want to try write PR ? You would just iterate here on ['post', 'patch', 'get', 'delete', 'options'] and apply the same logic.

kapusadam commented 6 years ago

Hi, hopefully I will have time next week and take a look at it!

pofider commented 6 years ago

I had to do some changes so I've also fixed the cors as requested. Please try the latest release.

Note that there are some breaking changes which you should check. https://github.com/pofider/node-simple-odata-server/releases/tag/1.0.0