bykof / cordova-plugin-webserver

A webserver plugin for cordova
Other
123 stars 49 forks source link

CORS Options #38

Open cloudfysystems opened 5 years ago

cloudfysystems commented 5 years ago

Hello,

I need to pass CORS headers into the OPTIONS request. Chrome block the request before it can get into the plugin:

`(window).webserver.onRequest( function (request) { debugger; console.log("O MA GAWD! This is the request: ", request);

                    (<any>window).webserver.sendResponse(
                        request.requestId,
                        {
                            status: 200,
                            body: '<html>Hello World</html>',
                            headers: {
                                'content-type': 'text/html',
                                "Access-Control-Allow-Origin": "*",
                                "Access-Control-Allow-Headers" : "content-type,transaction",
                                "Access-Control-Allow-Methods" : "GET,HEAD,PUT,PATCH,POST,DELETE"
                            }
                        }
                    );
                }
            );`

Is there any way to implement it?

dev-ankur commented 5 years ago

@cloudfysystems Its been months, have you got any solution? I really need to know! I'm using ionic 4.