🧑💻 Automatically guess env URLs for Vercel preview deploy… (#1076)
…ments <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new URL processing logic to enhance compatibility with Vercel preview environments. - Improved handling of environment-specific URLs for authentication and viewer services. - **Enhancements** - Streamlined environment variable management for more reliable deployment configurations. - **Documentation** - Updated documentation to reflect new environment variable processing functions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@ -8,6 +8,23 @@ const __filename = fileURLToPath(import.meta.url)
|
||||
|
||||
const __dirname = dirname(__filename)
|
||||
|
||||
const injectViewerUrlIfVercelPreview = (val) => {
|
||||
if (
|
||||
(val && typeof val === 'string' && val.length > 0) ||
|
||||
process.env.VERCEL_ENV !== 'preview' ||
|
||||
!process.env.VERCEL_BUILDER_PROJECT_NAME ||
|
||||
!process.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME
|
||||
)
|
||||
return
|
||||
process.env.NEXT_PUBLIC_VIEWER_URL =
|
||||
`https://${process.env.VERCEL_BRANCH_URL}`.replace(
|
||||
process.env.VERCEL_BUILDER_PROJECT_NAME,
|
||||
process.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME
|
||||
)
|
||||
}
|
||||
|
||||
injectViewerUrlIfVercelPreview(process.env.NEXT_PUBLIC_VIEWER_URL)
|
||||
|
||||
configureRuntimeEnv()
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
|
Reference in New Issue
Block a user