Static HTML file in public folder cannot be accessed in production build
See original GitHub issueIs this a bug report?
No
Did you try recovering your dependencies?
Yes
Environment
Environment: OS: Linux 4.17 Node: 8.10.0 Yarn: 1.7.0 npm: 6.1.0 Watchman: Not Found Xcode: N/A Android Studio: Not Found
Steps to Reproduce
- Generate React project with
npx create-react-app my-app
- Insert new
index.html
file in a subfolder in public. Mine is inpublic/home/index.html
- The above file path works in the development build, when I navigate to
localhost:3000/home/
. However, if I run a production build, I am no longer able to access this HTML file. Curiously, I’m able to access any other type of file, such aslocalhost:5000/home/js/random.js
, and even if I change the name ofindex.html
toindex.htm
, I’m able to navigate to it vialocalhost:5000/home/index.htm
. It’s just the specific case of the HTML file extension that seems to be blocked by something.
Expected Behavior
I would hope to find a way to take advantage of the public
directory to serve up my static HTML landing page. I wouldn’t necessarily call this a bug, but I’ve tried a bunch of webpack configurations, tried disabling the service worker, copywebpackplugin
, and none of it really worked to allow me to visit http://mysite/home
.
Any help is much appreciated!
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Using the Public Folder - Create React App
The public folder contains the HTML file so you can tweak it, for example, to set the page title. The <script> tag with...
Read more >Is it possible to serve Static files with create-react-app from ...
Yes, you can place assets in the static folder. Docs: Using the Public Folder. You can reference the path in index.html with ...
Read more >How to use files in public folder in ReactJS ? - GeeksforGeeks
The public folder contains static files such as index.html, ... Step 1: Create a React application using the following command:
Read more >Support - Netlify Support Forums
Issue: In production, netlify is not picking up on any of my glb models or some images from my public folder. Some of...
Read more >How to create a Static site public folder in Next.js? - Medium
With the public folder, you access everything in production or built time. ... You can add a verification HTML file inside the public...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hmm, it sounds like an issue needs to be opened with
serve
to serve a file when there’s an exact match on the file system.This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.