feat(remix): support serving app under a sub-path via NEXT_PUBLIC_BASE_PATH (#2824)

This commit is contained in:
Christopher Ryan
2026-08-12 16:12:28 +10:00
committed by GitHub
parent 962cffc9f5
commit 1bd09480e6
27 changed files with 189 additions and 50 deletions
@@ -1,4 +1,4 @@
import { NEXT_PUBLIC_WEBAPP_URL } from '@documenso/lib/constants/app';
import { formatPath, NEXT_PUBLIC_WEBAPP_URL } from '@documenso/lib/constants/app';
import {
isDisposableEmail,
isEmailDomainAllowedForSignup,
@@ -121,7 +121,7 @@ export const handleOAuthCallbackUrl = async (options: HandleOAuthCallbackUrlOpti
// Check if signups are disabled for this provider.
if (!isSignupEnabledForProvider(clientOptions.id as 'google' | 'microsoft' | 'oidc')) {
const errorUrl = new URL('/signin', NEXT_PUBLIC_WEBAPP_URL());
const errorUrl = new URL(formatPath('/signin'), NEXT_PUBLIC_WEBAPP_URL());
errorUrl.searchParams.set('error', AuthenticationErrorCode.SignupDisabled);
@@ -130,7 +130,7 @@ export const handleOAuthCallbackUrl = async (options: HandleOAuthCallbackUrlOpti
// Check domain restriction for new SSO users.
if (!isEmailDomainAllowedForSignup(email)) {
const errorUrl = new URL('/signin', NEXT_PUBLIC_WEBAPP_URL());
const errorUrl = new URL(formatPath('/signin'), NEXT_PUBLIC_WEBAPP_URL());
errorUrl.searchParams.set('error', AuthenticationErrorCode.SignupDisabled);
@@ -141,7 +141,7 @@ export const handleOAuthCallbackUrl = async (options: HandleOAuthCallbackUrlOpti
const additionalBlockedDomains = await getEmailBlocklistDomains();
if (isDisposableEmail(email, additionalBlockedDomains)) {
const errorUrl = new URL('/signin', NEXT_PUBLIC_WEBAPP_URL());
const errorUrl = new URL(formatPath('/signin'), NEXT_PUBLIC_WEBAPP_URL());
errorUrl.searchParams.set('error', AuthenticationErrorCode.SignupDisposableEmail);
@@ -213,15 +213,18 @@ export const validateOauth = async (options: HandleOAuthCallbackUrlOptions) => {
// eslint-disable-next-line prefer-const
let [redirectState, redirectPath] = storedRedirectPath.split(' ');
// The sub-path aware root, e.g. "/" or "/ESign/".
const defaultRedirectPath = formatPath('/');
if (redirectState !== storedState || !redirectPath) {
redirectPath = '/';
redirectPath = defaultRedirectPath;
}
if (!isValidReturnTo(redirectPath)) {
redirectPath = '/';
redirectPath = defaultRedirectPath;
}
redirectPath = normalizeReturnTo(redirectPath) || '/';
redirectPath = normalizeReturnTo(redirectPath) || defaultRedirectPath;
const tokens = await oAuthClient.validateAuthorizationCode(token_endpoint, code, storedCodeVerifier);