File tree 2 files changed +23
-2
lines changed
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,8 @@ const plugin: NetlifyPlugin = {
79
79
console . log ( `NextAuth package detected, setting NEXTAUTH_URL environment variable to ${ process . env . URL } ` )
80
80
81
81
const config = await getRequiredServerFiles ( publish )
82
- config . config . env . NEXTAUTH_URL = process . env . URL
82
+ const nextAuthUrl = `${ process . env . URL } ${ basePath } `
83
+ config . config . env . NEXTAUTH_URL = nextAuthUrl
83
84
84
85
await updateRequiredServerFiles ( publish , config )
85
86
}
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ const {
25
25
patchNextFiles,
26
26
unpatchNextFiles,
27
27
} = require ( '../plugin/src/helpers/files' )
28
- const { getRequiredServerFiles } = require ( '../plugin/src/helpers/config' )
28
+ const { getRequiredServerFiles, updateRequiredServerFiles } = require ( '../plugin/src/helpers/config' )
29
29
const { dirname } = require ( 'path' )
30
30
const { getProblematicUserRewrites } = require ( '../plugin/src/helpers/verification' )
31
31
@@ -241,6 +241,26 @@ describe('onBuild()', () => {
241
241
delete process . env . URL
242
242
} )
243
243
244
+ test ( 'includes the basePath on NEXTAUTH_URL when present' , async ( ) => {
245
+ const mockSiteUrl = 'https://my-netlify-site.app'
246
+ process . env . URL = mockSiteUrl
247
+
248
+ await moveNextDist ( )
249
+
250
+ const initialConfig = await getRequiredServerFiles ( netlifyConfig . build . publish )
251
+ initialConfig . config . basePath = "/foo"
252
+ await updateRequiredServerFiles ( netlifyConfig . build . publish , initialConfig )
253
+
254
+ await plugin . onBuild ( defaultArgs )
255
+
256
+ expect ( onBuildHasRun ( netlifyConfig ) ) . toBe ( true )
257
+ const config = await getRequiredServerFiles ( netlifyConfig . build . publish )
258
+
259
+ expect ( config . config . env . NEXTAUTH_URL ) . toEqual ( `${ mockSiteUrl } /foo` )
260
+
261
+ delete process . env . URL
262
+ } )
263
+
244
264
test ( 'skips setting NEXTAUTH_URL when next-auth package is not found' , async ( ) => {
245
265
isNextAuthInstalled . mockImplementation ( ( ) => {
246
266
return false
You can’t perform that action at this time.
0 commit comments