-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added temp patch for custom render
- fixes #52384
- Loading branch information
Showing
8 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react' | ||
|
||
export function PageIdentifier({ page }) { | ||
return ( | ||
<div id="page" data-page={page}> | ||
Page: {page} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
createNextDescribe( | ||
'custom-app-render', | ||
{ | ||
files: __dirname, | ||
skipDeployment: true, | ||
startCommand: 'node server.js', | ||
}, | ||
({ next }) => { | ||
it.each(['/', '/render'])('should render %s', async (page) => { | ||
const $ = await next.render$(page) | ||
expect($('#page').data('page')).toBe(page) | ||
}) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function App({ Component, pageProps }) { | ||
return <Component {...pageProps} /> | ||
} | ||
|
||
App.getInitialProps = async () => { | ||
return {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
|
||
import { PageIdentifier } from '../components/page-identifier' | ||
|
||
export default function IndexPage() { | ||
return <PageIdentifier page="/" /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
|
||
import { PageIdentifier } from '../components/page-identifier' | ||
|
||
export default function RenderNodePage() { | ||
return <PageIdentifier page="/render" /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const http = require('http') | ||
const { parse } = require('url') | ||
const next = require('next') | ||
|
||
async function main() { | ||
const dev = global.isNextDev || false | ||
process.env.NODE_ENV = dev ? 'development' : 'production' | ||
|
||
const port = parseInt(process.env.PORT, 10) || 3000 | ||
|
||
const app = next({ dev, port }) | ||
const handle = app.getRequestHandler() | ||
|
||
await app.prepare() | ||
|
||
const server = http.createServer(async (req, res) => { | ||
try { | ||
const parsedUrl = parse(req.url, true) | ||
const { pathname, query } = parsedUrl | ||
|
||
if (pathname.startsWith('/render')) { | ||
await app.render(req, res, pathname, query) | ||
} else { | ||
await handle(req, res, parsedUrl) | ||
} | ||
} catch (err) { | ||
res.statusCode = 500 | ||
res.end('Internal Server Error') | ||
} | ||
}) | ||
|
||
server.once('error', (err) => { | ||
console.error(err) | ||
process.exit(1) | ||
}) | ||
|
||
server.listen(port, () => { | ||
console.log( | ||
`> started server on url: http://localhost:${port} as ${ | ||
dev ? 'development' : process.env.NODE_ENV | ||
}` | ||
) | ||
}) | ||
} | ||
|
||
main().catch((err) => { | ||
console.error(err) | ||
process.exit(1) | ||
}) |