Use origin from header for baseUrl of emails (instead of AUTH_URL). Also removed reference to hide scrollbars

This commit is contained in:
bkellam 2025-03-23 21:22:38 -07:00
parent 484aea8406
commit 7d0540de13
5 changed files with 12 additions and 45 deletions

View file

@ -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<stri
return stripeClientNotInitialized();
}
const origin = (await headers()).get('origin')
const origin = (await headers()).get('origin')!;
const portalSession = await stripeClient.billingPortal.sessions.create({
customer: org.stripeCustomerId as string,
return_url: `${origin}/${domain}/settings/billing`,

View file

@ -252,7 +252,7 @@ export const SearchBar = ({
/>
<CodeMirror
ref={editorRef}
className="overflow-x-auto scrollbar-hide w-full"
className="overflow-x-auto w-full"
placeholder={isHistorySearchEnabled ? "Filter history..." : "Search (/) through repos..."}
value={query}
onChange={(value) => {

View file

@ -29,8 +29,8 @@ export default async function Login({ searchParams }: LoginProps) {
});
return (
<div className="flex flex-col min-h-screen">
<div className="flex-1 flex flex-col items-center p-4 sm:p-12 w-full bg-backgroundSecondary">
<div className="flex flex-col min-h-screen bg-backgroundSecondary">
<div className="flex-1 flex flex-col items-center p-4 sm:p-12 w-full">
<LoginForm
callbackUrl={searchParams.callbackUrl}
error={searchParams.error}

View file

@ -15,7 +15,7 @@ import { createTransport } from 'nodemailer';
import { render } from '@react-email/render';
import MagicLinkEmail from './emails/magicLinkEmail';
import { SINGLE_TENANT_ORG_ID } from './lib/constants';
import bcrypt from 'bcrypt';
import bcrypt from 'bcryptjs';
export const runtime = 'nodejs';
@ -59,9 +59,10 @@ export const getProviders = () => {
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",

View file

@ -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).*)',
],
}
}