File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
packages/plugin-rsc/examples/react-router Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,8 @@ async function prerender(nitro: Nitro, pages: string[]) {
167167 await nodeNitro . close ( )
168168
169169 async function prerenderPage ( page : { path : string } ) {
170- const encodedRoute = encodeURI ( page . path )
170+ // const encodedRoute = encodeURI(page.path)
171+ const encodedRoute = page . path
171172
172173 const res = await localFetch < Response > (
173174 withBase ( encodedRoute , nodeNitro . options . baseURL ) ,
@@ -185,7 +186,10 @@ async function prerender(nitro: Nitro, pages: string[]) {
185186 // const cleanPagePath = (prerenderOptions.outputPath || page.path).split(
186187 // /[?#]/,
187188 // )[0]!
188- const cleanPagePath = page . path
189+ const cleanPagePath = page // prerenderOptions.outputPath ||
190+ . path
191+ . split ( / [ ? # ] / ) [ 0 ] !
192+ // const cleanPagePath = page.path
189193
190194 // Guess route type and populate fileName
191195 const contentType = res . headers . get ( 'content-type' ) || ''
Original file line number Diff line number Diff line change @@ -28,15 +28,35 @@ export default defineConfig({
2828 } ,
2929 } ) ,
3030 inspect ( ) ,
31- ! ! process . env . NITRO_PRESET &&
31+ ! ! process . env . NITRO_PRESET && [
32+ {
33+ name : 'node-env' ,
34+ configEnvironment ( ) {
35+ // ensure running React production build on prerender.
36+ // otherwise Nitro's `NODE_ENV=prerender` breaks React.
37+ return {
38+ define : {
39+ 'process.env.NODE_ENV' : JSON . stringify ( 'production' ) ,
40+ } ,
41+ }
42+ } ,
43+ } ,
3244 nitroPlugin ( {
3345 preset : process . env . NITRO_PRESET as any ,
3446 // TODO: this can be inferred from config, such as
3547 // - builder.environments.client.config.build.outDir
3648 clientDir : path . resolve ( './dist/client' ) ,
3749 serverEntry : path . resolve ( './dist/ssr/index.js' ) ,
38- // prerender: ['/'],
50+ prerender : [
51+ '/' ,
52+ // '/_root.rsc',
53+ // '/about',
54+ '/about.rsc' ,
55+ // TODO(react-router): what is this?
56+ '/.manifest?p=%2F&p=%2Fabout' ,
57+ ] ,
3958 } ) ,
59+ ] ,
4060 ] ,
4161 optimizeDeps : {
4262 include : [ 'react-router' , 'react-router/internal/react-server-client' ] ,
You can’t perform that action at this time.
0 commit comments