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

Use cors on static files only? #270

Open
vedantroy opened this issue Jun 4, 2022 · 1 comment
Open

Use cors on static files only? #270

vedantroy opened this issue Jun 4, 2022 · 1 comment
Labels

Comments

@vedantroy
Copy link

I have the following line in my code:

app.use(express.static("public", { maxAge: "1h" }));

Ideally, I'd only allow cors on this route. What would be a good way to do that?

@dorward
Copy link

dorward commented Feb 22, 2024

As per the express documentation:

app.use([path,] callback [, callback...])

app.use(cors(options), express.static("public", { maxAge: "1h" }));

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

No branches or pull requests

3 participants