@@ -230,12 +230,12 @@ describe('onBuild()', () => {
230
230
} )
231
231
232
232
afterEach ( ( ) => {
233
- delete process . env . URL
233
+ delete process . env . DEPLOY_PRIME_URL
234
234
} )
235
235
236
236
test ( 'does not set NEXTAUTH_URL if value is already set' , async ( ) => {
237
237
const mockUserDefinedSiteUrl = chance . url ( )
238
- process . env . URL = chance . url ( )
238
+ process . env . DEPLOY_PRIME_URL = chance . url ( )
239
239
240
240
await moveNextDist ( )
241
241
@@ -252,13 +252,28 @@ describe('onBuild()', () => {
252
252
expect ( config . config . env . NEXTAUTH_URL ) . toEqual ( mockUserDefinedSiteUrl )
253
253
} )
254
254
255
+ test ( 'sets the NEXTAUTH_URL specified in the netlify.toml or in the Netlify UI' , async ( ) => {
256
+ const mockSiteUrl = chance . url ( )
257
+ process . env . NEXTAUTH_URL = mockSiteUrl
258
+
259
+ await moveNextDist ( )
260
+
261
+ await nextRuntime . onBuild ( defaultArgs )
262
+
263
+ expect ( onBuildHasRun ( netlifyConfig ) ) . toBe ( true )
264
+ const config = await getRequiredServerFiles ( netlifyConfig . build . publish )
265
+
266
+ expect ( config . config . env . NEXTAUTH_URL ) . toEqual ( mockSiteUrl )
267
+ delete process . env . NEXTAUTH_URL
268
+ } )
269
+
255
270
test ( 'sets NEXTAUTH_URL when next-auth package is detected' , async ( ) => {
256
271
const mockSiteUrl = chance . url ( )
257
272
258
273
// Value represents the main address to the site and is either
259
274
// a Netlify subdomain or custom domain set by the user.
260
275
// See https://docs.netlify.com/configure-builds/environment-variables/#deploy-urls-and-metadata
261
- process . env . URL = mockSiteUrl
276
+ process . env . DEPLOY_PRIME_URL = mockSiteUrl
262
277
263
278
await moveNextDist ( )
264
279
@@ -272,7 +287,7 @@ describe('onBuild()', () => {
272
287
273
288
test ( 'includes the basePath on NEXTAUTH_URL when present' , async ( ) => {
274
289
const mockSiteUrl = chance . url ( )
275
- process . env . URL = mockSiteUrl
290
+ process . env . DEPLOY_PRIME_URL = mockSiteUrl
276
291
277
292
await moveNextDist ( )
278
293
0 commit comments