Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
add xspace-agent/src/server/middleware/cors.ts
overstepping9f67b1853f17
diff --git a/xspace-agent/src/server/middleware/cors.ts b/xspace-agent/src/server/middleware/cors.tsnew file mode 100644index 000000000..46998208c--- /dev/null+++ b/xspace-agent/src/server/middleware/cors.ts@@ -0,0 +1,47 @@+// SPDX-License-Identifier: Apache-2.0+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§32]++import cors from "cors"+import type { RequestHandler } from "express"++export function createCorsMiddleware(): RequestHandler {+ const originsEnv = process.env.CORS_ORIGINS+ const allowedOrigins: string[] = []++ if (originsEnv) {+ allowedOrigins.push(+ ...originsEnv+ .split(",")+ .map((o) => o.trim())+ .filter(Boolean),+ )+ }++ const isDev = !process.env.ADMIN_API_KEY++ return cors({+ origin(origin, callback) {+ // Allow requests with no origin (same-origin, curl, mobile apps)+ if (!origin) {+ return callback(null, true)+ }++ // Always allow same-origin+ if (allowedOrigins.includes(origin)) {+ return callback(null, true)+ }++ // Dev mode: allow localhost on any port+ if (isDev && /^https?:\/\/localhost(:\d+)?$/.test(origin)) {+ return callback(null, true)+ }++ callback(new Error(`Origin ${origin} not allowed by CORS`))+ },+ credentials: true,+ methods: ["GET", "POST", "PUT", "DELETE", "PATCH"],+ allowedHeaders: ["Content-Type", "Authorization", "X-API-Key"],+ })+}++