Skip to content

Commit e4e0170

Browse files
Apply suggestions from code review
Co-authored-by: Nick Taylor <[email protected]>
1 parent 4ba1a59 commit e4e0170

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

packages/runtime/src/index.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ const plugin: NetlifyPlugin = {
138138
} else {
139139
// Using the deploy prime url in production leads to issues because the unique deploy ID is part of the generated URL
140140
// and will not match the expected URL in the callback URL of an OAuth application.
141-
const nextAuthUrl =
142-
process.env.CONTEXT === 'production'
143-
? `${process.env.URL}${basePath}`
144-
: `${process.env.DEPLOY_PRIME_URL}${basePath}`
141+
const nextAuthUrl = `${
142+
process.env.CONTEXT === 'production' ? process.env.URL : process.env.DEPLOY_PRIME_URL
143+
}${basePath}`
145144

146145
console.log(`NextAuth package detected, setting NEXTAUTH_URL environment variable to ${nextAuthUrl}`)
147146
config.config.env.NEXTAUTH_URL = nextAuthUrl

test/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ describe('onBuild()', () => {
278278
expect(config.config.env.NEXTAUTH_URL).toEqual(mockUserDefinedSiteUrl)
279279
})
280280

281-
test('sets the NEXTAUTH_URL to the URL when CONTEXT env variable is \'production\'', async () => {
281+
test('sets the NEXTAUTH_URL to the user defined site URL when CONTEXT env variable is \'production\'', async () => {
282282
const mockUserDefinedSiteUrl = chance.url()
283283
process.env.DEPLOY_PRIME_URL = chance.url()
284284
process.env.URL = mockUserDefinedSiteUrl

0 commit comments

Comments
 (0)