@decocms/runtime 1.0.0-alpha.26 → 1.0.0-alpha.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +15 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/runtime",
3
- "version": "1.0.0-alpha.26",
3
+ "version": "1.0.0-alpha.27",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@cloudflare/workers-types": "^4.20250617.0",
package/src/index.ts CHANGED
@@ -238,11 +238,25 @@ export const withBindings = <TEnv>({
238
238
  return env as TEnv;
239
239
  };
240
240
 
241
+ const DEFAULT_CORS_OPTIONS = {
242
+ origin: (origin: string) => {
243
+ // Allow localhost and configured origins
244
+ if (origin.includes("localhost") || origin.includes("127.0.0.1")) {
245
+ return origin;
246
+ }
247
+ // TODO: Configure allowed origins from environment
248
+ return origin;
249
+ },
250
+ credentials: true,
251
+ allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
252
+ allowHeaders: ["Content-Type", "Authorization", "mcp-protocol-version"],
253
+ };
254
+
241
255
  export const withRuntime = <TEnv, TSchema extends z.ZodTypeAny = never>(
242
256
  userFns: UserDefaultExport<TEnv, TSchema>,
243
257
  ) => {
244
258
  const server = createMCPServer<TEnv, TSchema>(userFns);
245
- const corsOptions = userFns.cors;
259
+ const corsOptions = userFns.cors ?? DEFAULT_CORS_OPTIONS;
246
260
  const oauth = userFns.oauth;
247
261
  const oauthHandlers = oauth ? createOAuthHandlers(oauth) : null;
248
262