React Router - Uncaught Syntaxerror: Unexpected Token < When Refreshing An Url With Params
I am using react 16 and react router 4, webpack and webpack dev server. I do have the following Route: A
Solution 1:
Posting the answer if it could help someone else.
Changing the output property of the webpack config to the following fixed the issue:
output:{
path: BUILD_DIR,
publicPath: '/',
filename: 'bundle.js',}
The trick is made by: publicPath: '/'
Solution 2:
I just had the same issue.
In my case, I had to add publicPath: '/'
as you mentioned in your answer and an opening /
in my script-src.
output: {
path: path.join(__dirname, "/public/dist"),
publicPath: '/',
filename: "[name].js",
}
Before: <script src="dist/main.js"></script>
(missing the opening /
)
After: <script src="/dist/main.js"></script>
Solution 3:
try this
You just need to add <base href="/" />
into the <head>
of your index.html
.
This resolved my problem. It may help you too.
https://github.com/vuejs-templates/pwa/issues/165#issuecomment-419709072
Post a Comment for "React Router - Uncaught Syntaxerror: Unexpected Token < When Refreshing An Url With Params"