Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions services/gastown/src/gastown.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,14 @@ app.use('/api/mayor/:townId/tools/rigs/:rigId/agents/:agentId/*', async (c, next

// ── CORS ────────────────────────────────────────────────────────────────
// Allow browser requests from the main Kilo app. In development, allow
// localhost origins for the Next.js dev server.
// localhost and LAN origins for the Next.js dev server.

const localIpPattern = /^https?:\/\/(localhost|127\.\d+\.\d+\.\d+|10\.\d+\.\d+\.\d+|172\.(1[6-9]|2[0-9]|3[0-1])\.\d+\.\d+|192\.168\.\d+\.\d+|\[(::1|fd[0-9a-f]{2}:[0-9a-f:]+|fe80:[0-9a-f:]+)\])(:\d+)?$/i;

const corsMiddleware = cors({
origin: (origin, c: Context<GastownEnv>) => {
if (c.env.ENVIRONMENT === 'development') {
// Allow any localhost origin in dev
if (origin.startsWith('http://localhost:')) return origin;
if (localIpPattern.test(origin)) return origin;
}
// Production origins
const allowed = ['https://app.kilo.ai', 'https://kilo.ai'];
Expand Down
6 changes: 4 additions & 2 deletions services/wasteland/src/wasteland.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ app.use('*', async (c, next) => {

// ── CORS ────────────────────────────────────────────────────────────────
// Allow browser requests from the main Kilo app. In development, allow
// localhost origins for the Next.js dev server.
// localhost and LAN origins for the Next.js dev server.

const localIpPattern = /^https?:\/\/(localhost|127\.\d+\.\d+\.\d+|10\.\d+\.\d+\.\d+|172\.(1[6-9]|2[0-9]|3[0-1])\.\d+\.\d+|192\.168\.\d+\.\d+|\[(::1|fd[0-9a-f]{2}:[0-9a-f:]+|fe80:[0-9a-f:]+)\])(:\d+)?$/i;

const corsMiddleware = cors({
origin: (origin, c: Context<WastelandEnv>) => {
if (c.env.ENVIRONMENT === 'development') {
if (origin.startsWith('http://localhost:')) return origin;
if (localIpPattern.test(origin)) return origin;
}
const allowed = ['https://app.kilo.ai', 'https://kilo.ai'];
return allowed.includes(origin) ? origin : '';
Expand Down