MIT License
This is a nuxt.js module that adds edge-level rewrite support.
There are conditions that we need to rewrite routes via reverse-proxy, like nginx. So that the final URL that users see is different from what is being rendered. This breaks SSR hydration process becuase client side router tries to render and hydrate an invalid URL.
This module fixes this problem by preserving original rendered URL in the universal state and faking vue-router
during initial render with History API. Users still see the requested URL because module reverts it back to the orginal non-rewritten one as soon as initial render happended.
Via NPM:
npm install nuxt-rewrite
Via Yarn:
yarn add nuxt-rewrite
Then add the module to the modules[]
section of nuxt.config
:
{
modules: [
'nuxt-rewrite'
]
}
<a>
tag that causes a SSR render during navigation so rewrite happensyarn
yarn dev
to run demo server./
route being rendered correctly!MIT