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

White listed origins not taking effect #56

Open
benigls opened this issue Dec 13, 2017 · 2 comments
Open

White listed origins not taking effect #56

benigls opened this issue Dec 13, 2017 · 2 comments

Comments

@benigls
Copy link

benigls commented Dec 13, 2017

I tried to test the restify-cors-middleware v1.1.0 using restify v4.3.2 and it seems ignoring the white listed origins. The code and test request that I used are below.

const restify = require('restify');
const corsMiddleware = require('restify-cors-middleware');

let server = restify.createServer({
  name: 'restify-test-cors'
});

const cors = corsMiddleware({
  origins: ['http://localhost:3000']
});

server.pre(cors.preflight);
server.use(cors.actual);

server.listen(8080, 'localhost', () => {
  console.log('running..');
});

server.get('/test', (req, res, next) => {
  res.send({ test: 'test' });
  next();
});
curl -v -X 'OPTIONS' -H 'Access-Control-Request-Method: GET' -H 'Origin: http://localhost:8000' 'http://localhost:8080/test'                                                                                                               
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> OPTIONS /test HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.47.0
> Accept: */*
> Access-Control-Request-Method: GET
> Origin: http://localhost:8000
> 
< HTTP/1.1 200 OK
< Allow: GET
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET
< Access-Control-Allow-Headers: accept, accept-version, content-type, request-id, origin, x-api-version, x-request-id
< Access-Control-Max-Age: 3600
< Date: Wed, 13 Dec 2017 08:13:21 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
< 
* Connection #0 to host localhost left intact
@benigls benigls changed the title Ignoring the white listed origins White listed origins not taking effect Dec 13, 2017
@giuseppepaul-axiell
Copy link

Did you manage to find a fix for this @benigls ?

@benigls
Copy link
Author

benigls commented Feb 23, 2018

@giuseppepaul-axiell I didn't. I tried testing it in v5 and v6 and it works.

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

No branches or pull requests

2 participants