@@ -230,12 +230,12 @@ describe('onBuild()', () => {
230230 } )
231231
232232 afterEach ( ( ) => {
233- delete process . env . URL
233+ delete process . env . DEPLOY_PRIME_URL
234234 } )
235235
236236 test ( 'does not set NEXTAUTH_URL if value is already set' , async ( ) => {
237237 const mockUserDefinedSiteUrl = chance . url ( )
238- process . env . URL = chance . url ( )
238+ process . env . DEPLOY_PRIME_URL = chance . url ( )
239239
240240 await moveNextDist ( )
241241
@@ -252,13 +252,28 @@ describe('onBuild()', () => {
252252 expect ( config . config . env . NEXTAUTH_URL ) . toEqual ( mockUserDefinedSiteUrl )
253253 } )
254254
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+
255270 test ( 'sets NEXTAUTH_URL when next-auth package is detected' , async ( ) => {
256271 const mockSiteUrl = chance . url ( )
257272
258273 // Value represents the main address to the site and is either
259274 // a Netlify subdomain or custom domain set by the user.
260275 // 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
262277
263278 await moveNextDist ( )
264279
@@ -272,7 +287,7 @@ describe('onBuild()', () => {
272287
273288 test ( 'includes the basePath on NEXTAUTH_URL when present' , async ( ) => {
274289 const mockSiteUrl = chance . url ( )
275- process . env . URL = mockSiteUrl
290+ process . env . DEPLOY_PRIME_URL = mockSiteUrl
276291
277292 await moveNextDist ( )
278293
0 commit comments