Open simplygreatwork opened 5 years ago
So i'm just trying to wrap the handle method and set the CORS headers - not successful yet...
Making some progress.
npm install --save cors
const cors = require('cors')();
const handle = server.handle.bind(server);
server.handle = function(req, res) {
cors(req, res, function() {
handle(req, res);
});
};
I think the issue with overriding handle is that you are removing the functionality it had before, we can either expose the ability to introspect on each request, which could be valid for other use cases, or have you tried:
const cors = require('cors')();
const oldHandle = server.handle;
server.handle = function(req, res) {
cors(req, res, function() {
oldHandle(req, res);
});
};
I am working with isomorphic-git in the browser. I will be able to connect to node-git-server using a proxy server - but I'm also exploring adding cors headers upon node-git-server requests. But I don't see any way to set a new header without overriding handle() and handlers. Any thoughts on how to approach this?