-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
historyApiFallback doesn't work, for scripts, if you're nested multiple path sections deep #216
Comments
Actually, if I change |
@ryancole I'm having the same problem, but changing the HTML script tag to match your example doesn't seem to solve it. Any way you could post your dev server config? |
Sure. My repository is here. A paste of the webpack config is ... 'use strict';
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:8081',
'webpack/hot/only-dev-server',
path.resolve(__dirname, 'src', 'App.js')
],
plugins: [
new webpack.HotModuleReplacementPlugin,
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
],
output: {
path: process.env.NODE_ENV === 'production' ?
path.resolve(__dirname, 'build', 'release', 'static') :
path.resolve(__dirname, 'build', 'debug', 'static'),
filename: 'app.js',
publicPath: '/static/'
},
resolve: {
alias: {
'bootstrap': 'bootstrap/dist'
}
},
devtool: 'source-map',
devServer: {
hot: true,
port: 8081,
colors: true,
publicPath: '/static/',
historyApiFallback: true
},
module: {
preLoaders: [
{
test: /\.js$/,
loader: "eslint-loader",
include: path.resolve(__dirname, 'src')
}
],
loaders: [
{
test: /\.js$/,
loaders: [
'react-hot',
'babel'
],
include: path.resolve(__dirname, 'src')
},
{
test: /\.json$/,
loader: 'json',
exclude: /node_modules/
},
{
test: /\.css/,
loaders: [
'style',
'css'
]
},
{
test: /\.woff2?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
},
{
test: /(\.ttf|\.eot|\.svg)$/,
loader: "file-loader"
}
]
}
}; |
@ryancole perfect, thanks! |
I'm having this issue as well. When my app is deployed to production, its basename will be "/eyeglass". Thus, I've told webpack to generate with a public path of "/eyeglass". In my single index.html file, all my resources are homed at "/eyeglass", e.g. "/eyeglass/styles.css", "/eyeglass/app.js" and so on. Locally, I'm starting the webpack-dev-server like this: If I navigate to "localhost:8080/eyeglass" my index.html is served up as expected. If I navigate directly to a deep URL, like "localhost:8080/eyeglass/reviews" the webpack-dev-server returns a 404. Any ideas? Here's the main snippet of my config:
|
+1 |
Currently HistoryApiFallback does not work properly when publicPath as it redirects request to /index.html which gives as it does not exist, instead we should redirect to publicPath (which redirects to publicPath/index.html). Fixes webpack#216
Currently HistoryApiFallback does not work properly when publicPath as it redirects request to /index.html which gives as it does not exist, instead we should redirect to publicPath (which redirects to publicPath/index.html). Fixes webpack#216
@manekinekko #518 doesnt't fix this issue. |
Use: |
Setting the base tag with '/' as href in your index.html fixes it. |
Which is the "correct" solution? Setting output.publicPath also solves it: |
I'm using
historyApiFallback
so that my react application can use the newer client-side routing / HTML 5 history. I've sethistoryApiFallback
totrue
. This works when the client-side route is something like/users
or/home
, etc. This does not seem to work if the client-side route is something like/users/1
, though. It tries to look for scripts within my HTML file relative to/users
. Even if my HTML script is like ...it looks for that at
/users/static/app.js
.The text was updated successfully, but these errors were encountered: