-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sst:main' into docs-fix-links
- Loading branch information
Showing
2 changed files
with
33 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#### Debug mode | ||
#### Debug mode | ||
|
||
OpenNext can be executed in debug mode by setting the environment variable `OPEN_NEXT_DEBUG=true`. | ||
OpenNext can be executed in debug mode by setting the environment variable `OPEN_NEXT_DEBUG=true`. | ||
|
||
This will output **A LOT** of additional logs to the console.This also disable minifying in esbuild, and add source maps to the output. This can result in code that might be up to 2-3X larger than the production build. **Do not enable this in production** | ||
|
||
|
@@ -23,20 +23,42 @@ experimental: { | |
}, | ||
}, | ||
``` | ||
|
||
Also you should not add sharp as a dependencies unless absolutely necessary, the image optimization already has it's own version of sharp. | ||
|
||
#### Patch fetch behaviour for ISR. Only for [email protected]+ | ||
|
||
If you use ISR and fetch in your app, you may encounter a bug that makes your revalidate values inconsistent. | ||
If you use ISR and fetch in your app, you may encounter a bug that makes your revalidate values inconsistent. | ||
The issue is that it revalidates using the lowest revalidate of all fetch calls in your page, regardless of their individual values. To fix this bug, you need to modify the fetch function in your root layout component with the following code snippet | ||
|
||
```ts | ||
export default function RootLayout() { | ||
const asyncStorage = require("next/dist/client/components/static-generation-async-storage.external"); | ||
const asyncStorage = require('next/dist/client/components/static-generation-async-storage.external'); | ||
//@ts-ignore | ||
const staticStore = (fetch as any).__nextGetStaticStore?.() || asyncStorage.staticGenerationAsyncStorage; | ||
const staticStore = | ||
(fetch as any).__nextGetStaticStore?.() || | ||
asyncStorage.staticGenerationAsyncStorage; | ||
const store = staticStore.getStore(); | ||
store.isOnDemandRevalidate = store.isOnDemandRevalidate && !(process.env.OPEN_NEXT_ISR === 'true'); | ||
store.isOnDemandRevalidate = | ||
store.isOnDemandRevalidate && !(process.env.OPEN_NEXT_ISR === 'true'); | ||
return <>...</>; | ||
} | ||
``` | ||
``` | ||
|
||
#### Access Denied errors on routes during page refresh and direct URL access | ||
|
||
If you are refreshing a dynamic/static route or going to that route directly from an URL. Like this route f.ex: | ||
`/profile/[userId]/[id]`, and you are getting an `Access Denied` error in XML: | ||
|
||
```xml | ||
<Error> | ||
<Code>AccessDenied</Code> | ||
<Message>Access Denied</Message> | ||
<RequestId>R4E6T9G2Q1S0Z5X8</RequestId> | ||
<HostId>S7h9F3g2T0z5K8d6A2s1W4x3C7v8B9m2L0j3K4i7H8g9F0r3A5q8w9E8r7t6Y5h4U3i2O1p0</HostId> | ||
</Error> | ||
``` | ||
|
||
This can also happen in app router when a client navigates via NextJS `<Link>` component. | ||
|
||
The issue might be that your having a folder or file in your `public` directory with an overlapping between the name and your route. In this case, you should rename that to something else. |
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