making "/index.html" accessible from the browser
See original GitHub issue… to make “index.html” accessible from browser?
I’m referring to your basic sample project. Everything is working as long as I’m browsing
localhost:3000
But if I call
localhost:3000/index.html
I’m getting
404 - Oh no's! We couldn't find that page :(
That wouldn’t be a big issue for me, but I’m hosting the app using sparkjava with a Jetty server behind. And this guy seems to rewrite any empty path to “index.html” -> 404 -> boom.
Any suggestion?
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
HTML: A good basis for accessibility - Learn web development
You should now be well-versed in writing accessible HTML for most occasions. Our WAI-ARIA basics article will help to fill gaps in this ......
Read more >HTML Accessibility - W3Schools
Always write HTML code with accessibility in mind! Provide the user a good way to navigate and interact ... Make your HTML code...
Read more >How to make an HTML file accessible to anyone on the internet
To make your website or webpage LIVE you should first select your domain name i.e your website name which will come in the...
Read more >Chrome Extensions creating a .html page accessible by ...
2. Open a local html page ... Then you can use chrome.tabs.create({ url: chrome.runtime.getURL("index.html") }); to open the local html page.
Read more >Making Content Accessible | Web Browser Engineering
Browsers therefore offer a range of accessibility features that take advantage of declarative UI and the flexibility of HTML and CSS to make...
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 Free
Top 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

I see what you’re saying. This is what’s happening:
/index.htmlinstead of/. In fact, this exact same problem would happen if you were to use create-react-app and react-router. React router will look for a route component withpath='/index.html'. When that route is not matched in the component tree, the fallback route is used, which in React Static’s case is the 404 component, naturally.The only ill-fated way to try and get around this is to somehow register your routes using the suffix, and this simply won’t fly with react-router or the filesystem. It would attempt to create
/index.html/index.html.There are also a slew of other issue that could arise in react-router and react-static because of that change, so I wouldn’t suggest attempting this.
In the end, you will be much better off by implementing a URL rewrite in your server configuration to remove the
.htmlsuffix and/indexpaths from routes that match an HTML file. This may or may not help you: http://www.eclipse.org/jetty/documentation/9.4.x/rewrite-handler.html.For anyone stumbling upon this issue, I was able to fix it using JS creating a script tag in the head with the following code
This method doesnt even redirect and will not show the 404 page because the /index.html path wont be there when react loads.
Maybe something similar can be implemented in the code base of react-static or maybe just documented so that people is aware of this.
In my case it was important because google for some reason was indexing /index.html and all my clients where getting to the 404 page.