Skip to content

Commit 94f6c17

Browse files
committed
fix: remove invalid NUXT_ENV_ prefix for Netlify env
1 parent c43de31 commit 94f6c17

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

config/env.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export const isProduction =
6060
*/
6161
export const getPreviewUrl = () =>
6262
isPreview
63-
? process.env.NUXT_ENV_URL
64-
? process.env.NUXT_ENV_URL
63+
? process.env.URL
64+
? process.env.URL
6565
: process.env.NUXT_ENV_VERCEL_URL
6666
? `https://${process.env.NUXT_ENV_VERCEL_URL}`
6767
: undefined
@@ -80,8 +80,8 @@ export const getPreviewUrl = () =>
8080
*/
8181
export const getProductionUrl = () =>
8282
isProduction
83-
? process.env.NUXT_ENV_URL
84-
? process.env.NUXT_ENV_URL
83+
? process.env.URL
84+
? process.env.URL
8585
: process.env.NUXT_ENV_VERCEL_PROJECT_PRODUCTION_URL
8686
? `https://${process.env.NUXT_ENV_VERCEL_PROJECT_PRODUCTION_URL}`
8787
: undefined

test/unit/config/env.spec.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
33
const ALL_ENV_VARS = [
44
'CONTEXT',
55
'VERCEL_ENV',
6-
'NUXT_ENV_URL',
6+
'URL',
77
'NUXT_ENV_VERCEL_URL',
88
'NUXT_ENV_VERCEL_PROJECT_PRODUCTION_URL',
99
]
@@ -31,7 +31,7 @@ describe('getPreviewUrl', () => {
3131
})
3232

3333
it.each([
34-
['Netlify production', { CONTEXT: 'production', NUXT_ENV_URL: 'https://prod.example.com' }],
34+
['Netlify production', { CONTEXT: 'production', URL: 'https://prod.example.com' }],
3535
['Vercel production', { VERCEL_ENV: 'production', NUXT_ENV_VERCEL_URL: 'prod.example.com' }],
3636
])('%s environment returns `undefined`', async (_name, envVars) => {
3737
for (const [key, value] of Object.entries(envVars)) {
@@ -43,29 +43,25 @@ describe('getPreviewUrl', () => {
4343
})
4444

4545
it.each([
46-
[
47-
'Netlify dev',
48-
{ CONTEXT: 'dev', NUXT_ENV_URL: 'https://dev.example.com' },
49-
'https://dev.example.com',
50-
],
46+
['Netlify dev', { CONTEXT: 'dev', URL: 'https://dev.example.com' }, 'https://dev.example.com'],
5147
[
5248
'Netlify deploy-preview',
5349
{
5450
CONTEXT: 'deploy-preview',
55-
NUXT_ENV_URL: 'https://preview.example.com',
51+
URL: 'https://preview.example.com',
5652
},
5753
'https://preview.example.com',
5854
],
5955
[
6056
'Netlify branch-deploy',
61-
{ CONTEXT: 'branch-deploy', NUXT_ENV_URL: 'https://beta.example.com' },
57+
{ CONTEXT: 'branch-deploy', URL: 'https://beta.example.com' },
6258
'https://beta.example.com',
6359
],
6460
[
6561
'Netlify preview-server',
6662
{
6763
CONTEXT: 'branch-deploy',
68-
NUXT_ENV_URL: 'https://my-feat--preview.example.com',
64+
URL: 'https://my-feat--preview.example.com',
6965
},
7066
'https://my-feat--preview.example.com',
7167
],
@@ -113,23 +109,20 @@ describe('getProductionUrl', () => {
113109
})
114110

115111
it.each([
116-
['Netlify dev', { CONTEXT: 'dev', NUXT_ENV_URL: 'https://dev.example.com' }],
112+
['Netlify dev', { CONTEXT: 'dev', URL: 'https://dev.example.com' }],
117113
[
118114
'Netlify deploy-preview',
119115
{
120116
CONTEXT: 'deploy-preview',
121-
NUXT_ENV_URL: 'https://preview.example.com',
117+
URL: 'https://preview.example.com',
122118
},
123119
],
124-
[
125-
'Netlify branch-deploy',
126-
{ CONTEXT: 'branch-deploy', NUXT_ENV_URL: 'https://beta.example.com' },
127-
],
120+
['Netlify branch-deploy', { CONTEXT: 'branch-deploy', URL: 'https://beta.example.com' }],
128121
[
129122
'Netlify preview-server',
130123
{
131124
CONTEXT: 'preview-server',
132-
NUXT_ENV_URL: 'https://my-feat--preview.example.com',
125+
URL: 'https://my-feat--preview.example.com',
133126
},
134127
],
135128
[
@@ -158,7 +151,7 @@ describe('getProductionUrl', () => {
158151
it.each([
159152
[
160153
'Netlify production',
161-
{ CONTEXT: 'production', NUXT_ENV_URL: 'https://prod.example.com' },
154+
{ CONTEXT: 'production', URL: 'https://prod.example.com' },
162155
'https://prod.example.com',
163156
],
164157
[

0 commit comments

Comments
 (0)