Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 2 additions & 6 deletions apps/app/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const config: NextConfig = {
async headers() {
return [
{
// Apply CORS headers to all API routes
// Super permissive CORS for all API routes
source: '/api/:path*',
headers: [
{
Expand All @@ -50,13 +50,9 @@ const config: NextConfig = {
key: 'Access-Control-Allow-Headers',
value: 'Content-Type, Authorization, X-Requested-With, Accept, Origin, x-pathname',
},
{
key: 'Access-Control-Allow-Credentials',
value: 'true',
},
{
key: 'Access-Control-Max-Age',
value: '86400', // 24 hours
value: '86400',
},
],
},
Expand Down
2 changes: 2 additions & 0 deletions apps/app/src/utils/auth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { createAuthClient } from 'better-auth/react';
import { auth } from './auth';
import { ac, allRoles } from './permissions';

console.log('process.env.NEXT_PUBLIC_BETTER_AUTH_URL', process.env.NEXT_PUBLIC_BETTER_AUTH_URL);

export const authClient = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_BETTER_AUTH_URL,
plugins: [
Expand Down
10 changes: 6 additions & 4 deletions apps/app/src/utils/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ if (env.AUTH_GITHUB_ID && env.AUTH_GITHUB_SECRET) {
};
}

console.log('process.env.BETTER_AUTH_URL', process.env.BETTER_AUTH_URL);

export const auth = betterAuth({
database: prismaAdapter(db, {
provider: 'postgresql',
}),
baseURL: process.env.BETTER_AUTH_URL,
trustedOrigins: [
'http://localhost:3000',
// 'http://localhost:3000',
'https://app.trycomp.ai',
'https://app.staging.trycomp.ai',
'https://portal.trycomp.ai',
'https://portal.staging.trycomp.ai',
// 'https://app.staging.trycomp.ai',
// 'https://portal.trycomp.ai',
// 'https://portal.staging.trycomp.ai',
],
emailAndPassword: {
enabled: true,
Expand Down
2 changes: 2 additions & 0 deletions apps/portal/src/app/lib/auth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
import { createAuthClient } from 'better-auth/react';
import { auth } from './auth';

console.log('process.env.NEXT_PUBLIC_BETTER_AUTH_URL', process.env.NEXT_PUBLIC_BETTER_AUTH_URL);

export const authClient = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_BETTER_AUTH_URL,
plugins: [organizationClient(), inferAdditionalFields<typeof auth>(), emailOTPClient()],
Expand Down
15 changes: 10 additions & 5 deletions apps/portal/src/app/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ export const auth = betterAuth({
generateId: false,
},
trustedOrigins: [
'http://localhost:3000',
// 'http://localhost:3000',
'https://app.trycomp.ai',
'https://app.staging.trycomp.ai',
'https://portal.trycomp.ai',
'https://portal.staging.trycomp.ai',
// 'https://app.staging.trycomp.ai',
// 'https://portal.trycomp.ai',
// 'https://portal.staging.trycomp.ai',
],
secret: process.env.AUTH_SECRET!,
plugins: [
organization({
async sendInvitationEmail(data) {
console.log(
'process.env.NEXT_PUBLIC_BETTER_AUTH_URL',
process.env.NEXT_PUBLIC_BETTER_AUTH_URL,
);

const isLocalhost = process.env.NODE_ENV === 'development';
const protocol = isLocalhost ? 'http' : 'https';
const domain = isLocalhost ? 'localhost:3000' : 'app.trycomp.ai';
const domain = isLocalhost ? 'localhost:3000' : process.env.NEXT_PUBLIC_BETTER_AUTH_URL!;
const inviteLink = `${protocol}://${domain}/invite/${data.invitation.id}`;

const url = `${protocol}://${domain}/auth`;
Expand Down
Loading