Skip to content

Commit 7d0540d

Browse files
Use origin from header for baseUrl of emails (instead of AUTH_URL). Also removed reference to hide scrollbars
1 parent 484aea8 commit 7d0540d

File tree

5 files changed

+12
-45
lines changed

5 files changed

+12
-45
lines changed

packages/web/src/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ export const createInvites = async (emails: string[], domain: string): Promise<{
710710
const inviteLink = `${origin}/redeem?invite_id=${invite.id}`;
711711
const transport = createTransport(env.SMTP_CONNECTION_URL);
712712
const html = await render(InviteUserEmail({
713-
baseUrl: env.AUTH_URL,
713+
baseUrl: origin,
714714
host: {
715715
name: session.user.name ?? undefined,
716716
email: session.user.email!,
@@ -1109,7 +1109,7 @@ export const createStripeCheckoutSession = async (domain: string) => sew(() =>
11091109
});
11101110
const numOrgMembers = orgMembers.length;
11111111

1112-
const origin = (await headers()).get('origin')
1112+
const origin = (await headers()).get('origin')!;
11131113
const prices = await stripeClient.prices.list({
11141114
product: env.STRIPE_PRODUCT_ID,
11151115
expand: ['data.product'],
@@ -1161,7 +1161,7 @@ export const getCustomerPortalSessionLink = async (domain: string): Promise<stri
11611161
return stripeClientNotInitialized();
11621162
}
11631163

1164-
const origin = (await headers()).get('origin')
1164+
const origin = (await headers()).get('origin')!;
11651165
const portalSession = await stripeClient.billingPortal.sessions.create({
11661166
customer: org.stripeCustomerId as string,
11671167
return_url: `${origin}/${domain}/settings/billing`,

packages/web/src/app/[domain]/components/searchBar/searchBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export const SearchBar = ({
252252
/>
253253
<CodeMirror
254254
ref={editorRef}
255-
className="overflow-x-auto scrollbar-hide w-full"
255+
className="overflow-x-auto w-full"
256256
placeholder={isHistorySearchEnabled ? "Filter history..." : "Search (/) through repos..."}
257257
value={query}
258258
onChange={(value) => {

packages/web/src/app/login/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export default async function Login({ searchParams }: LoginProps) {
2929
});
3030

3131
return (
32-
<div className="flex flex-col min-h-screen">
33-
<div className="flex-1 flex flex-col items-center p-4 sm:p-12 w-full bg-backgroundSecondary">
32+
<div className="flex flex-col min-h-screen bg-backgroundSecondary">
33+
<div className="flex-1 flex flex-col items-center p-4 sm:p-12 w-full">
3434
<LoginForm
3535
callbackUrl={searchParams.callbackUrl}
3636
error={searchParams.error}

packages/web/src/auth.ts

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { createTransport } from 'nodemailer';
1515
import { render } from '@react-email/render';
1616
import MagicLinkEmail from './emails/magicLinkEmail';
1717
import { SINGLE_TENANT_ORG_ID } from './lib/constants';
18-
import bcrypt from 'bcrypt';
18+
import bcrypt from 'bcryptjs';
1919

2020
export const runtime = 'nodejs';
2121

@@ -59,9 +59,10 @@ export const getProviders = () => {
5959
const token = String(Math.floor(100000 + Math.random() * 900000));
6060
return token;
6161
},
62-
sendVerificationRequest: async ({ identifier, provider, token }) => {
62+
sendVerificationRequest: async ({ identifier, provider, token, request }) => {
63+
const origin = request.headers.get('origin')!;
6364
const transport = createTransport(provider.server);
64-
const html = await render(MagicLinkEmail({ baseUrl: env.AUTH_URL, token: token }));
65+
const html = await render(MagicLinkEmail({ baseUrl: origin, token: token }));
6566
const result = await transport.sendMail({
6667
to: identifier,
6768
from: provider.from,
@@ -179,9 +180,6 @@ const onCreateUser = async ({ user }: { user: AuthJsUser }) => {
179180
}
180181
}
181182

182-
const useSecureCookies = env.AUTH_URL?.startsWith("https://") ?? false;
183-
const hostName = env.AUTH_URL ? new URL(env.AUTH_URL).hostname : "localhost";
184-
185183
export const { handlers, signIn, signOut, auth } = NextAuth({
186184
secret: env.AUTH_SECRET,
187185
adapter: PrismaAdapter(prisma),
@@ -213,37 +211,6 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
213211
return session;
214212
},
215213
},
216-
cookies: {
217-
sessionToken: {
218-
name: `${useSecureCookies ? '__Secure-' : ''}authjs.session-token`,
219-
options: {
220-
httpOnly: true,
221-
sameSite: 'lax',
222-
path: '/',
223-
secure: useSecureCookies,
224-
domain: `.${hostName}`
225-
}
226-
},
227-
callbackUrl: {
228-
name: `${useSecureCookies ? '__Secure-' : ''}authjs.callback-url`,
229-
options: {
230-
sameSite: 'lax',
231-
path: '/',
232-
secure: useSecureCookies,
233-
domain: `.${hostName}`
234-
}
235-
},
236-
csrfToken: {
237-
name: `${useSecureCookies ? '__Secure-' : ''}authjs.csrf-token`,
238-
options: {
239-
httpOnly: true,
240-
sameSite: 'lax',
241-
path: '/',
242-
secure: useSecureCookies,
243-
domain: `.${hostName}`
244-
}
245-
}
246-
},
247214
providers: getProviders(),
248215
pages: {
249216
signIn: "/login",

packages/web/src/middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ export async function middleware(request: NextRequest) {
3535
export const config = {
3636
// https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
3737
matcher: [
38-
'/((?!api|_next/static|ingest|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'
38+
'/((?!api|_next/static|ingest|_next/image|favicon.ico|sitemap.xml|robots.txt|sb_logo_light_large.png|arrow.png|placeholder_avatar.png).*)',
3939
],
40-
}
40+
}

0 commit comments

Comments
 (0)