You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is a detailed example of an `open-next.config.ts` file:
2
-
This file need to be at the same place as your `next.config.js` file
1
+
Here is a detailed example of an `open-next.config.ts` file. This file need to be at the same place as your `next.config.js` file
3
2
4
-
`server` in here could refer to a lambda function, a docker container, a node server or whatever that can support running nodejs code. (Even cloudflare workers in the future)
3
+
`server` in here could refer to a lambda function, a docker container, a node server or whatever that can support running nodejs code. Even Cloudflare workers (require to use `@opennextjs/cloudflare`).
5
4
6
-
For more information about the options here, take a look at the [components section](/aws/components/overview).
5
+
For more information about the options here, take a look at the [reference section](/aws/config/reference).
// Initialization function is a special server that will run at build time to initialize the cache.
109
+
// By default, it only initializes the tag cache. Besides the common options, you can use the following options:
110
+
initializationFunction: {
111
+
tagCache: 'dynamodb-lite', // Can be overridden with a LazyLoadedOverride
112
+
},
113
+
// Override the default revalidate function
114
+
// By default, works for lambda and on SQS event.
115
+
// Supports only node runtime
116
+
revalidate: {
117
+
override: {
118
+
wrapper: 'aws-lambda', // Can be overridden with a LazyLoadedOverride
119
+
converter: 'aws-apigw-v2', // Can be overridden with a LazyLoadedOverride
120
+
},
121
+
},
122
+
// Override the default warmer
123
+
// By default, works for lambda only.
124
+
// If you override this, you'll need to handle the warmer event in the wrapper
125
+
warmer: {
126
+
invokeFunction: 'aws-lambda', // Can be overridden with a LazyLoadedOverride
127
+
override: {
128
+
wrapper: 'aws-lambda', // Can be overridden with a LazyLoadedOverride
129
+
converter: 'aws-apigw-v2', // Can be overridden with a LazyLoadedOverride
130
+
},
131
+
},
79
132
// If you want to override the default build command, you can do it here
80
133
// By default it uses `npm run build`
81
-
buildCommand: "echo 'hello world'",
134
+
buildCommand: "echo 'skipping build'",
82
135
83
136
dangerous: {
84
137
// This will disable the tag cache
@@ -87,19 +140,38 @@ const config = {
87
140
// This will disable the incremental cache
88
141
// This is generally not recommended, as this is necessary for ISR AND SSG routes as well as the fetch cache
89
142
disableIncrementalCache: true,
90
-
}
91
-
92
-
//The path to the target folder of build output from the `buildCommand` option (the path which will contain the `.next` and `.open-next` folders). This path is relative from the current process.cwd() - Optional default to "."
93
-
buildOutputPath: "build",
94
-
95
-
//The path to the root of the Next.js app's source code. This path is relative from the current process.cwd(). - Optional default to "."
96
-
appPath: "app",
97
-
98
-
//The path to the package.json file of the Next.js app. This path is relative from the current process.cwd(). - Optional
99
-
packageJsonPath: "package.json",
100
-
101
-
} satisfiesOpenNextConfig
143
+
// Enable the cache interception. Every request will go through the cache interceptor, if it is found in the cache,
144
+
// it will be returned without going through NextServer. Not every feature is covered by the cache interceptor and
145
+
// it should fallback to the NextServer if the cache is not found.
146
+
enableCacheInterception: true,
147
+
// Function to determine which headers or cookies takes precedence.
148
+
// By default, the middleware headers and cookies will override the handler headers and cookies.
149
+
// This is executed for every request and after next config headers and middleware has executed.
150
+
// Here is a very simple example of how you can use it:
151
+
headersAndCookiesPriority: (event) => {
152
+
if (event.rawPath.startsWith('/api')) {
153
+
return'middleware';
154
+
}
155
+
return'handler';
156
+
},
157
+
},
158
+
// The path to the target folder of build output from the `buildCommand` option
159
+
// (the path which will contain the `.next` and `.open-next` folders).
160
+
// This path is relative from the current process.cwd() - Optional defaults to "."
161
+
buildOutputPath: 'build',
162
+
// The path to the root of the Next.js app's source code.
163
+
// This path is relative from the current process.cwd(). - Optional defaults to "."
164
+
appPath: 'app',
165
+
// The path to the package.json file of the Next.js app.
166
+
// This path is relative from the current process.cwd(). - Optional
167
+
packageJsonPath: 'package.json',
168
+
// Advanced usage
169
+
// If you use the edge runtime somewhere (either with an external middleware or in the functions), we compile 2 versions of the open-next.config.ts file.
170
+
// One for the node runtime and one for the edge runtime.
171
+
// This option allows you to specify the externals for the edge runtime used in esbuild for the compilation of open-next.config.ts
172
+
// It is especially useful if you use some custom overrides only in node
2. Update your `apps/next-site/next.config.js` add `output: ‘standalone’`, and you want to add `experimental.outputFileTracingRoot`, it should look a little like this:
@@ -122,7 +122,7 @@ now, when you run `nx open-next-build next-site`, nx will automatically build th
122
122
123
123
Now, we have a built app, ready to deploy, so how do we get it onto SST/AWS ? Good question!
124
124
125
-
We are using `sst ion` in this example. i will assume you have already have the cli installed, (if not, check here on how!)[https://ion.sst.dev/],
125
+
We are using `sst ion` in this example. i will assume you have already have the cli installed, [if not, check here on how](https://sst.dev),
126
126
but we will not use the SST cli to init this project, because it wants to add a package.json to your next app, and it will look like it's working, but you will end up with a big far server error (all because the package.json overrides whatever nx _thinks_ there should be, and it will miss a bunch of dependencies). we will instead manually set this up:
127
127
128
128
- let's add the sst package with `pnpm add sst@ion`, and the required packages for SST to work with AWS `pnpm add --save-dev aws-cdk-lib constructs @types/aws-lambda`
0 commit comments