@@ -40,6 +40,49 @@ export const isPreview =
4040 process . env . CONTEXT === 'dev' ||
4141 process . env . VERCEL_ENV === 'preview' ||
4242 process . env . VERCEL_ENV === 'development'
43+ export const isProduction =
44+ process . env . CONTEXT === 'production' || process . env . VERCEL_ENV === 'production'
45+
46+ /**
47+ * Environment variable `URL` provided by Netlify.
48+ * This is always the current deploy URL, regardless of env.
49+ * @see {@link https://docs.netlify.com/build/functions/environment-variables/#functions }
50+ *
51+ * Environment variable `VERCEL_URL` provided by Vercel.
52+ * This is always the current deploy URL, regardless of env.
53+ * NOTE: Not a valid URL, as the protocol is omitted.
54+ * @see {@link https://vercel.com/docs/environment-variables/system-environment-variables#VERCEL_URL }
55+ *
56+ * Preview URL for the current deployment, only available in preview environments.
57+ */
58+ export const getPreviewUrl = ( ) =>
59+ isPreview
60+ ? process . env . NUXT_ENV_URL
61+ ? process . env . NUXT_ENV_URL
62+ : process . env . NUXT_ENV_VERCEL_URL
63+ ? `https://${ process . env . NUXT_ENV_VERCEL_URL } `
64+ : undefined
65+ : undefined
66+
67+ /**
68+ * Environment variable `URL` provided by Netlify.
69+ * This is always the current deploy URL, regardless of env.
70+ * @see {@link https://docs.netlify.com/build/functions/environment-variables/#functions }
71+ *
72+ * Environment variable `VERCEL_PROJECT_PRODUCTION_URL` provided by Vercel.
73+ * NOTE: Not a valid URL, as the protocol is omitted.
74+ * @see {@link https://vercel.com/docs/environment-variables/system-environment-variables#VERCEL_PROJECT_PRODUCTION_URL }
75+ *
76+ * Production URL for the current deployment, only available in production environments.
77+ */
78+ export const getProductionUrl = ( ) =>
79+ isProduction
80+ ? process . env . NUXT_ENV_URL
81+ ? process . env . NUXT_ENV_URL
82+ : process . env . NUXTENV_VERCEL_PROJECT_PRODUCTION_URL
83+ ? `https://${ process . env . NUXT_ENV_VERCEL_PROJECT_PRODUCTION_URL } `
84+ : undefined
85+ : undefined
4386
4487const git = Git ( )
4588export async function getGitInfo ( ) {
@@ -92,5 +135,14 @@ export async function getEnv(isDevelopment: boolean) {
92135 : branch === 'main'
93136 ? 'canary'
94137 : 'release'
95- return { commit, shortCommit, branch, env } as const
138+ const previewUrl = getPreviewUrl ( )
139+ const productionUrl = getProductionUrl ( )
140+ return {
141+ commit,
142+ shortCommit,
143+ branch,
144+ env,
145+ previewUrl,
146+ productionUrl,
147+ } as const
96148}
0 commit comments