-
Notifications
You must be signed in to change notification settings - Fork 92
feat: configure ssr handler to only match known routes #2705
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
Draft
+363
−13
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4e13ef7
tests: add routing tests
orinokai 47be7cb
feat: configure ssr handler with known routes
orinokai 93b950a
feat: add additional routes to ssr paths
orinokai 0900155
feat: add basepath and i18n route handling to ssr function
orinokai e0a86dd
test: migrate from e2e to integration tests
orinokai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
File renamed without changes.
33 changes: 33 additions & 0 deletions
tests/fixtures/server-components/app/static-fetch-dynamic/[id]/page.js
This file contains hidden or 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,33 @@ | ||
export async function generateStaticParams() { | ||
return [{ id: '1' }, { id: '2' }] | ||
} | ||
|
||
async function getData(params) { | ||
const res = await fetch(`https://api.tvmaze.com/shows/${params.id}`, { | ||
next: { | ||
tags: [`show-${params.id}`], | ||
}, | ||
}) | ||
return res.json() | ||
} | ||
|
||
export default async function Page({ params }) { | ||
const data = await getData(params) | ||
|
||
return ( | ||
<> | ||
<h1>Hello, Force Dynamically Rendered Server Component</h1> | ||
<p>Paths /1 and /2 prerendered; other paths not found</p> | ||
<dl> | ||
<dt>Show</dt> | ||
<dd>{data.name}</dd> | ||
<dt>Param</dt> | ||
<dd>{params.id}</dd> | ||
<dt>Time</dt> | ||
<dd data-testid="date-now">{new Date().toISOString()}</dd> | ||
</dl> | ||
</> | ||
) | ||
} | ||
|
||
export const dynamic = 'force-dynamic' |
This file contains hidden or 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
/// <reference types="next/navigation-types/compat/navigation" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. | ||
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information. |
This file contains hidden or 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,3 @@ | ||
export default async function handler(req, res) { | ||
return res.send({ code: 200, message: 'okay' }) | ||
} |
This file contains hidden or 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,4 @@ | ||
export default function handler(req, res) { | ||
const { id } = req.query | ||
res.send({ code: 200, message: `okay ${id}` }) | ||
} |
This file contains hidden or 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,11 @@ | ||
export default function Yar({ title }) { | ||
return <h1>{title}</h1> | ||
} | ||
|
||
export async function getServerSideProps() { | ||
return { | ||
props: { | ||
title: 'My Page', | ||
}, | ||
} | ||
} |
This file contains hidden or 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,25 @@ | ||
export default function Page({ params }) { | ||
return ( | ||
<> | ||
<h1>Hello, Dyanmically fetched show</h1> | ||
<dl> | ||
<dt>Param</dt> | ||
<dd>{params.id}</dd> | ||
<dt>Time</dt> | ||
<dd data-testid="date-now">{new Date().toISOString()}</dd> | ||
</dl> | ||
</> | ||
) | ||
} | ||
|
||
export async function getServerSideProps({ params }) { | ||
const res = await fetch(`https://api.tvmaze.com/shows/${params.id}`) | ||
const data = await res.json() | ||
|
||
return { | ||
props: { | ||
params, | ||
data, | ||
}, | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
tests/fixtures/server-components/pages/posts/prerendered/[id].js
This file contains hidden or 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,33 @@ | ||
export default function Page({ params }) { | ||
return ( | ||
<> | ||
<h1>Hello, Statically fetched show</h1> | ||
<p>Paths /1 and /2 prerendered; other paths not found</p> | ||
<dl> | ||
<dt>Param</dt> | ||
<dd>{params.id}</dd> | ||
<dt>Time</dt> | ||
<dd data-testid="date-now">{new Date().toISOString()}</dd> | ||
</dl> | ||
</> | ||
) | ||
} | ||
|
||
export async function getStaticPaths() { | ||
return { | ||
paths: [{ params: { id: '1' } }, { params: { id: '2' } }], | ||
fallback: false, | ||
} | ||
} | ||
|
||
export async function getStaticProps({ params }) { | ||
const res = await fetch(`https://api.tvmaze.com/shows/${params.id}`) | ||
const data = await res.json() | ||
|
||
return { | ||
props: { | ||
params, | ||
data, | ||
}, | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.