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
1 change: 1 addition & 0 deletions .github/workflows/deploy-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/preview-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions products/backend/drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default {
out: './drizzle',
dbCredentials: {
url: `${process.env.DATABASE_URL}`,
// ssl: {
// rejectUnauthorized: false,
// },
ssl: {
rejectUnauthorized: false,
},
Comment on lines +9 to +11

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid forcing SSL for all drizzle-kit connections

This config now enables SSL unconditionally. The local development Postgres in compose.yaml uses the stock postgres:latest image without SSL certs configured, which rejects SSL connections by default. As a result, drizzle-kit generate/migrate/studio will fail locally with a “server does not support SSL” error when using the standard DATABASE_URL. Consider gating ssl on an environment flag or encoding sslmode in DATABASE_URL so local dev remains usable.

Useful? React with 👍 / 👎.

Comment on lines +9 to +11

Copilot AI Jan 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting rejectUnauthorized: false disables SSL certificate validation, which creates a security vulnerability by allowing man-in-the-middle attacks. While this might be necessary for development or certain database providers, it should be avoided in production. Consider making this configurable via an environment variable so it can be set to true in production while allowing false for development environments where self-signed certificates might be used.

Copilot uses AI. Check for mistakes.
},
} satisfies Config;
2 changes: 1 addition & 1 deletion products/backend/src/auth.cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],

Copilot AI Jan 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding the production URL 'https://pay-crew2.yukiosada.work' in trustedOrigins reduces maintainability and makes the code less flexible across different environments (staging, preview, production). Consider extracting this to an environment variable or deriving it from the existing BETTER_AUTH_URL to make the configuration more maintainable and environment-agnostic.

Copilot uses AI. Check for mistakes.
socialProviders: {
discord: {
clientId: process.env.DISCORD_CLIENT_ID as string,
Expand Down
2 changes: 1 addition & 1 deletion products/backend/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],

Copilot AI Jan 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding the production URL 'https://pay-crew2.yukiosada.work' in trustedOrigins reduces maintainability and makes the code less flexible across different environments (staging, preview, production). Consider extracting this to an environment variable or deriving it from the existing BETTER_AUTH_URL to make the configuration more maintainable and environment-agnostic.

Copilot uses AI. Check for mistakes.
socialProviders: {
discord: {
clientId: env.DISCORD_CLIENT_ID,
Expand Down
2 changes: 1 addition & 1 deletion products/frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_API_URL=

VITE_REDIRECT_URL=
4 changes: 2 additions & 2 deletions products/frontend/src/routes/Root/index.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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,
});
};

Expand Down
3 changes: 3 additions & 0 deletions setup/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -36,6 +38,7 @@ export const dotenvLoader = (): EnvConfig => {

const frontendConfig: FrontendConfig = {
viteApiUrl,
viteRedirectUrl,
};
const backendConfig: BackendConfig = {
postgresUser,
Expand Down
1 change: 1 addition & 0 deletions setup/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions setup/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type EnvConfig = {

export type FrontendConfig = {
viteApiUrl: string;
viteRedirectUrl: string;
};

export type BackendConfig = {
Expand Down