mirror of
https://github.com/Xevion/icons.git
synced 2025-12-16 20:11:57 -06:00
Add VERCEL_URl to env with URL parsing & transformation
This commit is contained in:
11
src/env.mjs
11
src/env.mjs
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
import { z } from "zod";
|
||||
import {z} from "zod";
|
||||
|
||||
/**
|
||||
* Specify your server-side environment variables schema here.
|
||||
@@ -15,6 +15,12 @@ const server = z.object({
|
||||
* To expose them to the client, prefix them with `NEXT_PUBLIC_`.
|
||||
*/
|
||||
const client = z.object({
|
||||
NEXT_PUBLIC_APP_URL: z.string().transform(url => {
|
||||
// Add a HTTPS url prefix automatically, for vercel.
|
||||
if (!(url.startsWith("http://") || url.startsWith("https://")))
|
||||
return `https://${url}`;
|
||||
return url;
|
||||
})
|
||||
// NEXT_PUBLIC_CLIENTVAR: z.string().min(1),
|
||||
});
|
||||
|
||||
@@ -25,6 +31,7 @@ const client = z.object({
|
||||
*/
|
||||
const processEnv = {
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
NEXT_PUBLIC_APP_URL: process.env.VERCEL_URL ?? process.env.APP_URL
|
||||
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
|
||||
};
|
||||
|
||||
@@ -70,4 +77,4 @@ if (!!process.env.SKIP_ENV_VALIDATION == false) {
|
||||
});
|
||||
}
|
||||
|
||||
export { env };
|
||||
export {env};
|
||||
|
||||
Reference in New Issue
Block a user