-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[v2] Properly serve static files #7952
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️ oh wow! Not sure why we didn't notice that express.static wasn't doing it's job and that we thought we had to recreate it haha :-)
Holy buckets, @Yurickh — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
any idea why this doesn't seem to work? a regression perhaps? storing an html page in |
I'm having the same issue. As a temporary solution I'm using this plugin: https://www.gatsbyjs.org/packages/gatsby-plugin-static-folders/ |
I'll take a look at it. 🎉 |
Reported new issue #13072 |
Issue #2352 brought to my attention that
express.static
wasn't serving any static files, leaving all the heavy lifting to lines 161-187.This is due to the fact that
__dirname
is the local filename, not the project root.Actually, express uses the place from where the node process is called (usually the project root) as the actual root for serving static files, so I just went ahead and removed it.
Before, having a public folder like:
Would raise 404 for
/my-custom-folder
, but not for/my-custom-folder/index.html
or/my-custom-folder/
.Now, when accessing
/my-custom-folder
, we're getting redirected to/my-custom-folder/
, as one might expect.Edit: this was originally intended to go with v2, but I guess we can hotfix it down to v1 as well?
Closes #2352
Closes freeCodeCamp/freeCodeCamp#18093