jaystack / odata-v4-server

With JayStack OData v4 Server you can build your own data endpoints without the hassle of implementing any protocol-level code. This framework binds OData v4 requests to your annotated controller functions, and compiles OData v4 compatible response. Clients can access services through OData-compliant HTTP requests. We recommend the JayData library for consuming OData v4 APIs.
https://jaystack.com/products/jaystack-odata-v4-server/
75 stars 55 forks source link

CORS pre-flight in server instance #58

Open rhexo opened 3 years ago

rhexo commented 3 years ago

Hi.

I'm trying to use this odata-v4-server as a service with sap open ui5 framework in couple. Using @odata.cors don't satisfy requirements of open ui5 because they actively using "options" request for pre-flight check. In this case i enhance static create method of class ODataServerBase to support pre-flight conditions in this way

.... if (server.cors) { var corsOpt = { origin: ['http://localhost:8080', 'http://localhost'], optionsSuccessStatus: 204, exposedHeaders: ['OData-Version'] } router.options('*', cors(corsOpt)) router.use(cors(corsOpt)); }

May be exists another way, supported by this odata-v4-server api? Using a router class as optional parameter of create method can be is alternative solution.

P.S. using router instance, that returned by create method(without port parameter request) has no effect. If reffer to documentation of npm cors package, using pre-flight conditions have to declare before any router definition in express instance.