diff --git a/packages/web/src/actions.ts b/packages/web/src/actions.ts index 2fce05d5..e96e1292 100644 --- a/packages/web/src/actions.ts +++ b/packages/web/src/actions.ts @@ -710,7 +710,7 @@ export const createInvites = async (emails: string[], domain: string): Promise<{ const inviteLink = `${origin}/redeem?invite_id=${invite.id}`; const transport = createTransport(env.SMTP_CONNECTION_URL); const html = await render(InviteUserEmail({ - baseUrl: env.AUTH_URL, + baseUrl: origin, host: { name: session.user.name ?? undefined, email: session.user.email!, @@ -1109,7 +1109,7 @@ export const createStripeCheckoutSession = async (domain: string) => sew(() => }); const numOrgMembers = orgMembers.length; - const origin = (await headers()).get('origin') + const origin = (await headers()).get('origin')!; const prices = await stripeClient.prices.list({ product: env.STRIPE_PRODUCT_ID, expand: ['data.product'], @@ -1161,7 +1161,7 @@ export const getCustomerPortalSessionLink = async (domain: string): Promise { diff --git a/packages/web/src/app/login/page.tsx b/packages/web/src/app/login/page.tsx index f8b8b010..50fd3ef8 100644 --- a/packages/web/src/app/login/page.tsx +++ b/packages/web/src/app/login/page.tsx @@ -29,8 +29,8 @@ export default async function Login({ searchParams }: LoginProps) { }); return ( -
-
+
+
{ const token = String(Math.floor(100000 + Math.random() * 900000)); return token; }, - sendVerificationRequest: async ({ identifier, provider, token }) => { + sendVerificationRequest: async ({ identifier, provider, token, request }) => { + const origin = request.headers.get('origin')!; const transport = createTransport(provider.server); - const html = await render(MagicLinkEmail({ baseUrl: env.AUTH_URL, token: token })); + const html = await render(MagicLinkEmail({ baseUrl: origin, token: token })); const result = await transport.sendMail({ to: identifier, from: provider.from, @@ -179,9 +180,6 @@ const onCreateUser = async ({ user }: { user: AuthJsUser }) => { } } -const useSecureCookies = env.AUTH_URL?.startsWith("https://") ?? false; -const hostName = env.AUTH_URL ? new URL(env.AUTH_URL).hostname : "localhost"; - export const { handlers, signIn, signOut, auth } = NextAuth({ secret: env.AUTH_SECRET, adapter: PrismaAdapter(prisma), @@ -213,37 +211,6 @@ export const { handlers, signIn, signOut, auth } = NextAuth({ return session; }, }, - cookies: { - sessionToken: { - name: `${useSecureCookies ? '__Secure-' : ''}authjs.session-token`, - options: { - httpOnly: true, - sameSite: 'lax', - path: '/', - secure: useSecureCookies, - domain: `.${hostName}` - } - }, - callbackUrl: { - name: `${useSecureCookies ? '__Secure-' : ''}authjs.callback-url`, - options: { - sameSite: 'lax', - path: '/', - secure: useSecureCookies, - domain: `.${hostName}` - } - }, - csrfToken: { - name: `${useSecureCookies ? '__Secure-' : ''}authjs.csrf-token`, - options: { - httpOnly: true, - sameSite: 'lax', - path: '/', - secure: useSecureCookies, - domain: `.${hostName}` - } - } - }, providers: getProviders(), pages: { signIn: "/login", diff --git a/packages/web/src/middleware.ts b/packages/web/src/middleware.ts index b8c1580c..25aeba72 100644 --- a/packages/web/src/middleware.ts +++ b/packages/web/src/middleware.ts @@ -35,6 +35,6 @@ export async function middleware(request: NextRequest) { export const config = { // https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher matcher: [ - '/((?!api|_next/static|ingest|_next/image|favicon.ico|sitemap.xml|robots.txt).*)' + '/((?!api|_next/static|ingest|_next/image|favicon.ico|sitemap.xml|robots.txt|sb_logo_light_large.png|arrow.png|placeholder_avatar.png).*)', ], -} \ No newline at end of file +}