diff --git a/.github/workflows/deploy-frontend.yaml b/.github/workflows/deploy-frontend.yaml index 3ce4205..a1e02c8 100644 --- a/.github/workflows/deploy-frontend.yaml +++ b/.github/workflows/deploy-frontend.yaml @@ -24,6 +24,7 @@ jobs: - name: Build env: VITE_API_URL: ${{ secrets.VITE_API_URL }} + VITE_REDIRECT_URL: ${{ secrets.VITE_REDIRECT_URL }} run: nix develop --command bash -c "pnpm i && pnpm run build" # Deploy Frontend to Cloudflare Workers - name: Deploy Frontend to Cloudflare Workers diff --git a/.github/workflows/preview-frontend.yaml b/.github/workflows/preview-frontend.yaml index 9ff0c9b..13b8e5e 100644 --- a/.github/workflows/preview-frontend.yaml +++ b/.github/workflows/preview-frontend.yaml @@ -26,6 +26,7 @@ jobs: id: build env: VITE_API_URL: ${{ secrets.VITE_API_URL }} + VITE_REDIRECT_URL: ${{ secrets.VITE_REDIRECT_URL }} run: nix develop --command bash -c "pnpm i && pnpm run frontend:build" # Deploy Preview to Cloudflare Workers # Ref: https://zenn.dev/lalalatotoro/articles/b8fa632b53d332 diff --git a/products/backend/drizzle.config.ts b/products/backend/drizzle.config.ts index 66c9636..8a905a8 100644 --- a/products/backend/drizzle.config.ts +++ b/products/backend/drizzle.config.ts @@ -6,8 +6,8 @@ export default { out: './drizzle', dbCredentials: { url: `${process.env.DATABASE_URL}`, - // ssl: { - // rejectUnauthorized: false, - // }, + ssl: { + rejectUnauthorized: false, + }, }, } satisfies Config; diff --git a/products/backend/src/auth.cli.ts b/products/backend/src/auth.cli.ts index cae568d..bd991e7 100644 --- a/products/backend/src/auth.cli.ts +++ b/products/backend/src/auth.cli.ts @@ -25,7 +25,7 @@ export const auth = betterAuth({ secret: process.env.BETTER_AUTH_SECRET as string, baseURL: process.env.BETTER_AUTH_URL as string, // allow requests from the frontend development server - trustedOrigins: ['http://localhost:5173'], + trustedOrigins: ['https://pay-crew2.yukiosada.work', 'http://localhost:5173'], socialProviders: { discord: { clientId: process.env.DISCORD_CLIENT_ID as string, diff --git a/products/backend/src/auth.ts b/products/backend/src/auth.ts index 77eaa3e..0fbb483 100644 --- a/products/backend/src/auth.ts +++ b/products/backend/src/auth.ts @@ -31,7 +31,7 @@ export const auth = (env: Bindings) => { secret: env.BETTER_AUTH_SECRET, baseURL: env.BETTER_AUTH_URL, // allow requests from the frontend development server - trustedOrigins: ['http://localhost:5173'], + trustedOrigins: ['https://pay-crew2.yukiosada.work', 'http://localhost:5173'], socialProviders: { discord: { clientId: env.DISCORD_CLIENT_ID, diff --git a/products/frontend/.env.example b/products/frontend/.env.example index 39cc927..59a578e 100644 --- a/products/frontend/.env.example +++ b/products/frontend/.env.example @@ -1,2 +1,2 @@ VITE_API_URL= - +VITE_REDIRECT_URL= diff --git a/products/frontend/src/routes/Root/index.tsx b/products/frontend/src/routes/Root/index.tsx index 2021204..41ef12c 100644 --- a/products/frontend/src/routes/Root/index.tsx +++ b/products/frontend/src/routes/Root/index.tsx @@ -1,5 +1,5 @@ import type { FC } from 'react'; -import { authClient } from '../..//lib/auth'; +import { authClient } from '../../lib/auth'; //tmp import { $api } from '../../api/fetchClient'; @@ -12,7 +12,7 @@ const Root: FC = () => { const handleDiscordSignin = async () => { await authClient.signIn.social({ provider: 'discord', - callbackURL: 'http://localhost:5173/', + callbackURL: import.meta.env.VITE_REDIRECT_URL satisfies string, }); }; diff --git a/setup/src/functions.ts b/setup/src/functions.ts index 3c6c618..655de08 100644 --- a/setup/src/functions.ts +++ b/setup/src/functions.ts @@ -9,6 +9,7 @@ export const dotenvLoader = (): EnvConfig => { const caster = new DotEnvCaster(); const viteApiUrl = caster.castString(process.env.VITE_API_URL); + const viteRedirectUrl = caster.castString(process.env.VITE_REDIRECT_URL); const postgresUser = caster.castString(process.env.POSTGRES_USER); const postgresPassword = caster.castString(process.env.POSTGRES_PASSWORD); const postgresDb = caster.castString(process.env.POSTGRES_DB); @@ -24,6 +25,7 @@ export const dotenvLoader = (): EnvConfig => { console.info('Environment variables loaded from .env file'); console.table({ VITE_API_URL: viteApiUrl, + VITE_REDIRECT_URL: viteRedirectUrl, POSTGRES_USER: postgresUser, POSTGRES_PASSWORD: postgresPassword ? '*****' : '', POSTGRES_DB: postgresDb, @@ -36,6 +38,7 @@ export const dotenvLoader = (): EnvConfig => { const frontendConfig: FrontendConfig = { viteApiUrl, + viteRedirectUrl, }; const backendConfig: BackendConfig = { postgresUser, diff --git a/setup/src/index.ts b/setup/src/index.ts index b5e9fa8..1b29e32 100644 --- a/setup/src/index.ts +++ b/setup/src/index.ts @@ -17,6 +17,7 @@ const main = () => { { // frontend const frontendDotenvData = `VITE_API_URL=${envConfig.frontendConfig.viteApiUrl} +VITE_REDIRECT_URL=${envConfig.frontendConfig.viteRedirectUrl} `; fileWriter('./products/frontend/.env', frontendDotenvData); } diff --git a/setup/src/types.ts b/setup/src/types.ts index c1441de..56c44c8 100644 --- a/setup/src/types.ts +++ b/setup/src/types.ts @@ -5,6 +5,7 @@ export type EnvConfig = { export type FrontendConfig = { viteApiUrl: string; + viteRedirectUrl: string; }; export type BackendConfig = {