Skip to content
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

Error on refresh #1056

Closed
daniel7912 opened this issue Sep 26, 2016 · 14 comments
Closed

Error on refresh #1056

daniel7912 opened this issue Sep 26, 2016 · 14 comments

Comments

@daniel7912
Copy link

The app works great if I leave everything as the default and use npm start, but when I change:

RouterModule.forRoot(ROUTES, {useHash: true}) to:

RouterModule.forRoot(ROUTES, {useHash: false})

I am getting errors on refresh. If I load/refresh the app at http://localhost:3000 it works fine still, but if I try refreshing while I'm one of the other pages, e.g. http://localhost:3000/about then I get this error:

<% if (webpackConfig.htmlElements.headTags) { %> <%= webpackConfig.htmlElements.headTags %> <% } %> Loading... <% if (webpackConfig.metadata.isDevServer && webpackConfig.metadata.HMR !== true) { %> <% } %>

Anyone know how to stop this from happening? Thanks!

@fmoessle
Copy link

+1

@aminebizid
Copy link

Try removing completely useHash

@noorahmed94
Copy link

I am facing the same issue with my code. The code runs well but on refresh the application stucks. Somehow webpackConfig is undefined in <% if (webpackConfig.htmlElements.headTags) { %>

@DanielMcAssey
Copy link

DanielMcAssey commented Sep 27, 2016

Im getting the same problem, when HMR reloads the page on non-root (e.g. http://localhost:3000/help) it just shows these tags.

@fmoessle
Copy link

@Zigzag95
changing
RouterModule.forRoot(ROUTES, { useHash: true }),
to
RouterModule.forRoot(ROUTES)
did not solve my problem

@DanielMcAssey
Copy link

Tried the same fix as @fmoessle and updating to the latest Node v6.6.0, still not working.

@fmoessle
Copy link

I changed

"webpack-dev-middleware": "^1.6.1", "webpack-dev-server": "^2.1.0-beta.2",
to
"webpack-dev-middleware": "1.6.1", "webpack-dev-server": "2.1.0-beta.2",

now its working with:
RouterModule.forRoot(ROUTES)
or
RouterModule.forRoot(ROUTES, { useHash: true })

@wilfredmifsud
Copy link

fmoessle this worked

@DanielMcAssey
Copy link

@fmoessle that fix worked for me. Thanks

@smorcuend
Copy link
Contributor

It seems that,
"webpack-dev-server": ">=2.1.0-beta.6"
breaks the workflow when user accesses from path http://localhost:3000/about without hash strategy as entry point to the app.

@fmoessle
Copy link

you can also try this fantastic repo with Universal, WebpackBeta25, AOT, and Angular 2.0.1
https://github.com/qdouble/angular2webpack2-starter

@theRaffe
Copy link

theRaffe commented Dec 1, 2016

Please, Help!
Haven't this been fixed yet?
Im facing the same problem, I have webpack-dev-server : 2.1.0-beta11

@LehaMotovilov
Copy link

Same problem.

"webpack": "2.1.0-beta.27",
"webpack-dev-middleware": "1.6.1",
"webpack-dev-server": "2.1.0-beta.6",

@lucaritossa
Copy link

I'm using these packs and I'm facing the same issue...

"webpack": "2.3.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-dev-server": "2.4.1"

I solved putting this option into devServer configuration

historyApiFallback: {
      index: '/foo-app/'
},

Please pay attention, I'm also using publicPath because I'm running my app on a custom path, different from '/' (ie: http://localhost:3000/foo-app/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests