()
| 17 | * different host) set ALLOWED_ORIGINS and get a mounted middleware here. |
| 18 | */ |
| 19 | export const buildCors = () => { |
| 20 | if (env.ALLOWED_ORIGINS.length === 0) { |
| 21 | return undefined; |
| 22 | } |
| 23 | |
| 24 | return cors({ |
| 25 | origin: env.ALLOWED_ORIGINS, |
| 26 | credentials: true, |
| 27 | methods: CORS_METHODS, |
| 28 | allowedHeaders: CORS_ALLOWED_HEADERS, |
| 29 | exposeHeaders: CORS_EXPOSED_HEADERS, |
| 30 | maxAge: CORS_MAX_AGE_SECONDS, |
| 31 | aot: true, |
| 32 | }); |
| 33 | }; |
| 34 | |
| 35 | /** |
| 36 | * Rate-limit storage picker. The default `elysia-rate-limit` context is |