Skip to content

Commit

Permalink
Merge branch 'sst:main' into docs-fix-links
Browse files Browse the repository at this point in the history
  • Loading branch information
sommeeeer authored Jun 14, 2024
2 parents 5069021 + 8e0cdce commit 7134762
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
36 changes: 29 additions & 7 deletions docs/pages/common_issues.mdx
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**

Expand All @@ -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.
6 changes: 4 additions & 2 deletions docs/pages/config.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
### Build Arguments

There is a single build argument that you can pass to the `open-next build` command:
There is two build arguments that you can pass to the `open-next build` command:

- `--config-path` - This is the path to the configuration file that you want to use. By default, it will look for `open-next.config.ts` in the current working directory. This needs to be relative to the current working directory.
- `--node-externals` - You can configure externals for the esbuild compilation of the `open-next.config.ts` file (i.e `--node-externals @aws-sdk/*,open-next/dist/queue/*`)

### Configuration File

Expand All @@ -13,4 +15,4 @@ If you want to take a look at some simple configuration examples, you can check

For more advanced use cases, you can check [how to implement custom overrides](/config/custom_overrides).

If you want to look at a full example, you can check [the full example](/config/full_example).
If you want to look at a full example, you can check [the full example](/config/full_example).

0 comments on commit 7134762

Please sign in to comment.