Skip to content

Commit d2e5d5b

Browse files
committed
fix: resolve CORS credentials issue
- Change CORS origin from regex pattern to exact origin from env variable - Update Dockerfile with proper environment variables - Fix 'Access-Control-Allow-Origin must not be wildcard with credentials' error Fixes CORS error: Response to preflight request doesn't pass access control check
1 parent b46b4df commit d2e5d5b

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

apps/backend/Dockerfile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,22 @@ COPY tsconfig.json .
1111
COPY drizzle.config.ts .
1212
COPY ./drizzle ./drizzle
1313

14+
# Install debugging tools for testing
15+
RUN apt-get update && apt-get install -y curl netcat-openbsd && rm -rf /var/lib/apt/lists/*
16+
1417
# COPY public public
1518

16-
ENV NODE_ENV production
19+
ENV NODE_ENV=production
20+
ENV TRUST_PROXY=true
21+
ENV HOST=0.0.0.0
22+
ENV PORT=8080
23+
24+
# Required environment variables for the application
25+
ENV DATABASE_URL="sqlite://app.db"
26+
ENV SUPABASE_URL="https://placeholder.supabase.co"
27+
ENV SUPABASE_KEY="placeholder-key"
28+
ENV CORS_ORIGIN="https://eventer.betich.me"
29+
1730
CMD ["bun", "src/index.ts"]
1831

1932
EXPOSE 8080

apps/backend/src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@ import { userRouter } from "./modules/user";
1111
const app = new Elysia({})
1212
.use(
1313
cors({
14-
// origin: "https://eventer.betich.me",
15-
origin: /.*\.betich\.me$/,
16-
// [
17-
// /.*\.betich\.me$/,
18-
// process.env.NODE_ENV === "development" ? /localhost:\d+/ : "",
19-
// env.CORS_ORIGIN || "",
20-
// ],
14+
origin: env.CORS_ORIGIN, // Use exact origin from environment variable
2115
credentials: true,
2216
preflight: true,
2317
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],

0 commit comments

Comments
 (0)