pofider / node-simple-odata-server

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

Adds router options to allow OPTIONS check pass. #21

Closed jaszczw closed 7 years ago

jaszczw commented 7 years ago

This solves issue when you try to make a CORS request from browser, headers still need to be handled on the user side, but it won't throw stating that such endpoint doesn't not exist.

Feel free to discard if you have had reasons for doing it such way.

pofider commented 7 years ago

I see, thank you. I'm actually using this library only behind express with cors middle-ware so I didn't come to this...

Shouldn't the options be responded then for all routes?

Maybe this regexp would do it

this.router.options('/.*', function (req, res) {
     res.end();
});
jaszczw commented 7 years ago

I have made update to pull-request: You are right the /.* is more generic and fits perfectly here. Thanks for feedback.

pofider commented 7 years ago

I'm now missing a comment on your https://github.com/pofider/node-simple-odata-server/pull/21/commits/9b4035eca7e40ec4b65a9aba7028408c3272f941 commit

jaszczw commented 7 years ago

Yeah, sorry about that - i am using my master branch in job and here I have done pull-request directly from it.

The /.* didn't work as there was pathToRegex transformation done on it and I couldn't grasp how exactly I would have to write it in order for it to work, as I had limited amount of time to work on that issue I had just reverted the changes to what I knew worked.

pofider commented 7 years ago

Ok, thanks for info, I'll take a look

pofider commented 7 years ago

Thank you for your hints. Release 0.3.0 has cors config https://github.com/pofider/node-simple-odata-server#cors