configurable NEXT_PUBLIC_WEBAPP_URL

This commit is contained in:
Timur Ercan
2023-01-16 14:25:55 +01:00
parent b4f795ad10
commit 801548cbd6
5 changed files with 10 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import { Disclosure, Menu, Transition } from "@headlessui/react";
import Link from "next/link";
import { useRouter } from "next/router";
import { signOut, useSession } from "next-auth/react";
import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants";
import Navigation from "./navigation";
@ -16,7 +17,7 @@ function useRedirectToLoginIfUnauthenticated() {
router.replace({
pathname: "/login",
query: {
callbackUrl: `https://app.documenso.com/${location.pathname}${location.search}`,
callbackUrl: `${NEXT_PUBLIC_WEBAPP_URL}/${location.pathname}${location.search}`,
},
});
}

View File

@ -8,6 +8,7 @@ import { ErrorCode } from "@documenso/lib/auth";
import { useState } from "react";
import { useRouter } from "next/router";
import { toast, Toaster } from "react-hot-toast";
import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants";
interface LoginValues {
email: string;
@ -29,7 +30,9 @@ export default function Login() {
// If not absolute URL, make it absolute
if (!/^https?:\/\//.test(callbackUrl)) {
callbackUrl = `https://app.documenso.com/${callbackUrl}`;
if (process.env.NODE_ENV !== "production") {
}
callbackUrl = `${NEXT_PUBLIC_WEBAPP_URL}/${callbackUrl}`;
}
const onSubmit = async (values: LoginValues) => {

View File

@ -1,3 +1,4 @@
import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants";
import { XCircleIcon } from "@heroicons/react/24/outline";
import { signIn } from "next-auth/react";
import Link from "next/link";
@ -44,7 +45,7 @@ export default function Signup() {
.then(async () => {
await signIn<"credentials">("credentials", {
...data,
callbackUrl: "https://app.documenso.com/dashboard",
callbackUrl: `${NEXT_PUBLIC_WEBAPP_URL}/dashboard`,
});
}),
{