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 Support by default #53

Closed
igneel64 opened this issue Mar 15, 2020 · 1 comment · Fixed by #54
Closed

CORS Support by default #53

igneel64 opened this issue Mar 15, 2020 · 1 comment · Fixed by #54

Comments

@igneel64
Copy link

igneel64 commented Mar 15, 2020

Feature request

(This came from my use of the snapstub package)
Allowing CORS support.
Currently trying to mock some API calls in another localhost instance, the user is faced with CORS issues if the user-agent requires an OPTIONS request.
The handlings that exists currently does not seem to prevent this case:
See

app.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});

Steps to Reproduce the Problem

  1. Start a local application on a different port than the server.
  2. Request a resource that would require an OPTIONS request.
  3. CORS issue occurs
    Tested in latest Google Chrome

Resolution

By only the addition of the cors middleware, the server is able to handle the OPTIONS request correctly and then move on and allow us to use this package as expected.

If the maintainers think this is a valid request, I can create a PR as soon as possible

@ruyadorno
Copy link
Collaborator

ruyadorno commented Mar 16, 2020

Sure thing 👍 I think it does make sense and a PR would be welcome 😄 it would be nice to also have some tests to make sure it doesn't break again in the future 😊 Thanks!

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

Successfully merging a pull request may close this issue.

2 participants