aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastien Castiel <sebastien@castiel.me>2024-01-19 12:43:08 -0500
committerSebastien Castiel <sebastien@castiel.me>2024-01-19 12:43:17 -0500
commitc138afadb9a7c6e04113ea6a7fd19d0f46050e68 (patch)
treeb87ce0ac668b59001aff2078fd0f842ced77244d /src
parent18ac2142a8544069267640fa1f6f9b92356c2cce (diff)
Bring back NEXT_PUBLIC_BASE_URL
Diffstat (limited to 'src')
-rw-r--r--src/app/robots.ts5
-rw-r--r--src/app/sitemap.ts19
-rw-r--r--src/lib/env.ts8
3 files changed, 19 insertions, 13 deletions
diff --git a/src/app/robots.ts b/src/app/robots.ts
index 2492611..5fb07a6 100644
--- a/src/app/robots.ts
+++ b/src/app/robots.ts
@@ -1,3 +1,4 @@
+import { env } from '@/lib/env'
import { MetadataRoute } from 'next'
export default function robots(): MetadataRoute.Robots {
@@ -7,8 +8,6 @@ export default function robots(): MetadataRoute.Robots {
allow: '/',
disallow: '/groups/',
},
- sitemap: process.env.VERCEL_URL
- ? `${process.env.VERCEL_URL}/sitemap.xml`
- : undefined,
+ sitemap: `${env.NEXT_PUBLIC_BASE_URL}/sitemap.xml`,
}
}
diff --git a/src/app/sitemap.ts b/src/app/sitemap.ts
index 7dfbba7..a3b92a1 100644
--- a/src/app/sitemap.ts
+++ b/src/app/sitemap.ts
@@ -1,14 +1,13 @@
+import { env } from '@/lib/env'
import { MetadataRoute } from 'next'
export default function sitemap(): MetadataRoute.Sitemap {
- return process.env.VERCEL_URL
- ? [
- {
- url: process.env.VERCEL_URL,
- lastModified: new Date(),
- changeFrequency: 'yearly',
- priority: 1,
- },
- ]
- : []
+ return [
+ {
+ url: env.NEXT_PUBLIC_BASE_URL,
+ lastModified: new Date(),
+ changeFrequency: 'yearly',
+ priority: 1,
+ },
+ ]
}
diff --git a/src/lib/env.ts b/src/lib/env.ts
index 31b91e7..3db102e 100644
--- a/src/lib/env.ts
+++ b/src/lib/env.ts
@@ -3,6 +3,14 @@ import { z } from 'zod'
const envSchema = z.object({
POSTGRES_URL_NON_POOLING: z.string().url(),
POSTGRES_PRISMA_URL: z.string().url(),
+ NEXT_PUBLIC_BASE_URL: z
+ .string()
+ .optional()
+ .default(
+ process.env.VERCEL_URL
+ ? `https://${process.env.VERCEL_URL}`
+ : 'http://localhost:3000',
+ ),
})
export const env = envSchema.parse(process.env)