aboutsummaryrefslogtreecommitdiff
path: root/src/config/cors.ts
blob: 6d6e138cd707203e2f322a127111ab1d9745ec88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { config } from "dotenv";
import { cors } from "hono/cors";

config();

const allowedOrigins = process.env.ANIWATCH_API_CORS_ALLOWED_ORIGINS
  ? process.env.ANIWATCH_API_CORS_ALLOWED_ORIGINS.split(",")
  : ["http://localhost:4000", "*"];

const corsConfig = cors({
  allowMethods: ["GET"],
  maxAge: 600,
  credentials: true,
  origin: allowedOrigins,
});

export default corsConfig;