-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
404 on home page if public directory exists in the root of the project #1100
Comments
One possible fix is to delete default static fallback into Here is part of the code that cause this issue: json-server/src/server/defaults.js Lines 11 to 15 in 622400f
|
@typicode hi! What do you think about removing default |
I figured the better solution is to separate creation of users static server from static server that is used for serving json-server related stuff. |
My solution : const fs = require('fs');
const path = require('path');
const server = require('json-server');
const routes = require('./routes');
const app = server.create();
const middlewares = server.defaults({
static: path.join(__dirname, '../node_modules/json-server/public')
}); |
Or in my case, I added the static route on the config file
|
When I change the the page that Why is that ? |
If there is
public
directory in the root of the project then json-server attempts to serve index.html from there, as result the home page is not working.Steps for reproduction of the bug:
public
directory in the root of this new projectnpx json-server db.json
http://localhost:3000/
Expected behavior: home page should work
Actual behavior: home page doesn't work (404 error)
The text was updated successfully, but these errors were encountered: