Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS Headers #53

Open
simplygreatwork opened this issue Mar 16, 2019 · 3 comments
Open

CORS Headers #53

simplygreatwork opened this issue Mar 16, 2019 · 3 comments
Assignees

Comments

@simplygreatwork
Copy link

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?

@simplygreatwork
Copy link
Author

So i'm just trying to wrap the handle method and set the CORS headers - not successful yet...

@simplygreatwork
Copy link
Author

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);
	});
};

@gabrielcsapo
Copy link
Owner

gabrielcsapo commented Mar 31, 2019

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);
	});
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants