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

Allow CORS on static file serving #104

Closed
shekspir55 opened this issue Feb 15, 2017 · 3 comments
Closed

Allow CORS on static file serving #104

shekspir55 opened this issue Feb 15, 2017 · 3 comments
Assignees
Labels

Comments

@shekspir55
Copy link

Hello, and thank you for this wonderful lib, dynamic options are the greatest.

Now to problem.
I have this configuration,
app.options('*', cors());
All static files are loading well but the font files which returns CORS issue.
Static file serving is done this way.
app.use(express.static(myParh))

Thank you.

@dougwilson dougwilson self-assigned this Mar 23, 2017
@dougwilson
Copy link
Contributor

Hi @shekspir55 it's hard to really say without getting the full app from you to run and debug, but I can at least say that it is probably due to the wrong usage of the module -- you need to app.use this module:

app.use(cors)

The app.options is only a subset and will not apply CORS to the "simple requests", which assets (like fonts) typically are.

I hope that helps!

@pguardiario
Copy link

I noticed that app.use(cors) needs to be above the static folder lines.

@outdoteth

This comment has been minimized.

@expressjs expressjs locked as resolved and limited conversation to collaborators Oct 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants