-
Notifications
You must be signed in to change notification settings - Fork 155
Fix fallback false #858
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
Merged
Merged
Fix fallback false #858
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dbe3198
fix 404 for fallback false
conico974 fd85949
fix fallback multiple dynamic route
conico974 ab8a3c1
fix issue with trailing slash and better handling of dynamic fallback
conico974 851af13
add e2e test
conico974 e087cb6
changeset & lint
conico974 54a8b34
fix unit-test
conico974 ccdb493
update comment
conico974 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
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,5 @@ | ||
--- | ||
"@opennextjs/aws": patch | ||
--- | ||
|
||
fix 404 with fallback false on dynamic route |
20 changes: 20 additions & 0 deletions
20
examples/pages-router/src/pages/fallback-intercepted/[...slugs].tsx
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,20 @@ | ||
import type { InferGetServerSidePropsType } from "next"; | ||
|
||
export function getServerSideProps() { | ||
return { | ||
props: { | ||
message: "This is a dynamic fallback page.", | ||
}, | ||
}; | ||
} | ||
|
||
export default function Page({ | ||
message, | ||
}: InferGetServerSidePropsType<typeof getServerSideProps>) { | ||
return ( | ||
<div> | ||
<h1>Dynamic Fallback Page</h1> | ||
<p data-testid="message">{message}</p> | ||
</div> | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
examples/pages-router/src/pages/fallback-intercepted/[slug].tsx
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 @@ | ||
import type { InferGetStaticPropsType } from "next"; | ||
|
||
export function getStaticPaths() { | ||
return { | ||
paths: [ | ||
{ | ||
params: { | ||
slug: "fallback", | ||
}, | ||
}, | ||
], | ||
fallback: false, | ||
}; | ||
} | ||
|
||
export function getStaticProps() { | ||
return { | ||
props: { | ||
message: "This is a static fallback page.", | ||
}, | ||
}; | ||
} | ||
|
||
export default function Page({ | ||
message, | ||
}: InferGetStaticPropsType<typeof getStaticProps>) { | ||
return ( | ||
<div> | ||
<h1>Static Fallback Page</h1> | ||
<p data-testid="message">{message}</p> | ||
</div> | ||
); | ||
} |
20 changes: 20 additions & 0 deletions
20
examples/pages-router/src/pages/fallback-intercepted/ssg.tsx
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,20 @@ | ||
import type { InferGetStaticPropsType } from "next"; | ||
|
||
export function getStaticProps() { | ||
return { | ||
props: { | ||
message: "This is a static ssg page.", | ||
}, | ||
}; | ||
} | ||
|
||
export default function Page({ | ||
message, | ||
}: InferGetStaticPropsType<typeof getStaticProps>) { | ||
return ( | ||
<div> | ||
<h1>Static Fallback Page</h1> | ||
<p data-testid="message">{message}</p> | ||
</div> | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
examples/pages-router/src/pages/fallback-intercepted/static.tsx
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,8 @@ | ||
export default function Page() { | ||
return ( | ||
<div> | ||
<h1>Static Fallback Page</h1> | ||
<p data-testid="message">This is a fully static page.</p> | ||
</div> | ||
); | ||
} |
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 @@ | ||
import type { InferGetStaticPropsType } from "next"; | ||
|
||
export function getStaticPaths() { | ||
return { | ||
paths: [ | ||
{ | ||
params: { | ||
slug: "fallback", | ||
}, | ||
}, | ||
], | ||
fallback: false, | ||
}; | ||
} | ||
|
||
export function getStaticProps() { | ||
return { | ||
props: { | ||
message: "This is a static fallback page.", | ||
}, | ||
}; | ||
} | ||
|
||
export default function Page({ | ||
message, | ||
}: InferGetStaticPropsType<typeof getStaticProps>) { | ||
return ( | ||
<div> | ||
<h1>Static Fallback Page</h1> | ||
<p data-testid="message">{message}</p> | ||
</div> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test.describe("fallback", () => { | ||
test("should work with fully static fallback", async ({ page }) => { | ||
await page.goto("/fallback-intercepted/static/"); | ||
const h1 = page.locator("h1"); | ||
await expect(h1).toHaveText("Static Fallback Page"); | ||
const p = page.getByTestId("message"); | ||
await expect(p).toHaveText("This is a fully static page."); | ||
}); | ||
|
||
test("should work with static fallback", async ({ page }) => { | ||
await page.goto("/fallback-intercepted/ssg/"); | ||
const h1 = page.locator("h1"); | ||
await expect(h1).toHaveText("Static Fallback Page"); | ||
const p = page.getByTestId("message"); | ||
await expect(p).toHaveText("This is a static ssg page."); | ||
}); | ||
|
||
test("should work with fallback intercepted by dynamic route", async ({ | ||
page, | ||
}) => { | ||
await page.goto("/fallback-intercepted/something/"); | ||
const h1 = page.locator("h1"); | ||
await expect(h1).toHaveText("Dynamic Fallback Page"); | ||
const p = page.getByTestId("message"); | ||
await expect(p).toHaveText("This is a dynamic fallback page."); | ||
}); | ||
|
||
test("should work with fallback page pregenerated", async ({ page }) => { | ||
await page.goto("/fallback-intercepted/fallback/"); | ||
const h1 = page.locator("h1"); | ||
await expect(h1).toHaveText("Static Fallback Page"); | ||
const p = page.getByTestId("message"); | ||
await expect(p).toHaveText("This is a static fallback page."); | ||
}); | ||
|
||
test("should 404 on page not pregenerated", async ({ request }) => { | ||
const res = await request.get("/fallback/not-generated"); | ||
expect(res.status()).toBe(404); | ||
}); | ||
}); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could that cause issue with minification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need to test it. Not sure what we can use if we can't use that, i don't think we can use
instanceof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does work in cloudflare in preview
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a concern, there is a
keep_classname
option in the webpack config.