fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

nextjs HMR always reload index page #73

Closed acanimal closed 7 years ago

acanimal commented 7 years ago

From what I have experienced, since version 1.0.40 it seems nextjs always reloads the index page.

fridays commented 7 years ago

Could you share a sample to reproduce the issue?

acanimal commented 7 years ago

In development the nextjs app checks for code updates invoking /_next/on-demand-entries-ping?page=/ which results in a message like Client pings, but there's no entry for page: on server side and produces the whole app will be loaded.

I think it has something to do with this https://github.com/fridays/next-routes/blob/master/src/index.js#L125

Looking in the file history the problem is introduced in this commit https://github.com/fridays/next-routes/commit/1afd1dd38b6e26f8ac6468f3dff845f384d2f73f. Using again the this.page = page.replace(/^\/?(.*)/, '/$1') line seems to fix the problem and now the nextjs HTML tries to refresh content calling /_next/on-demand-entries-ping?page=/index instead not existent /_next/on-demand-entries-ping?page=/

fridays commented 7 years ago

The URL is correct actually (try without next-routes). I can't see any issues, please share some code to reproduce it.

acanimal commented 7 years ago

Maybe is due this fix you done in last release of nextjs: https://github.com/zeit/next.js/pull/2505 We have a previous version. I'll try to update and check.

fridays commented 7 years ago

Is it solved?