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

Add CORS package to the core #141

Open
franciscop opened this issue Jan 18, 2022 · 1 comment
Open

Add CORS package to the core #141

franciscop opened this issue Jan 18, 2022 · 1 comment

Comments

@franciscop
Copy link
Owner

Is your feature request related to a problem? Please describe.
One of the basic features of APIs is to be able to work nicely with CORS. This is not possible with Server.js, and instead you need to either install a third party package or do it manually.

Describe the solution you'd like
Have the cors package be a part of the core. It should be disabled by default, but easily be able to do:

server({ cors: false });   // Default (to keep it retro-compatible)
server({ cors: "*" });
server({ cors: "https://serverjs.io" });
server({ cors: ["https://serverjs.io", "http://localhost:3000"] });
server({
  cors: { origin: "https://serverjs.io",  methods: ["GET", "PUT", "POST"] }
});

Describe alternatives you've considered
Using the cors package; it'd be nice to have it in the core so we don't need to install it each time.

Additional context
Since server.js is supposed to work nicely both as an API server and as a renderer (traditional) server, this makes making an API easier.

@ghost

This comment was marked as off-topic.

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

1 participant