Skip to content

chore(cors): broaden local origin matching for dev environments#4012

Open
IamCoder18 wants to merge 1 commit into
Kilo-Org:mainfrom
IamCoder18:feat/cors-broaden-local-ip-pattern
Open

chore(cors): broaden local origin matching for dev environments#4012
IamCoder18 wants to merge 1 commit into
Kilo-Org:mainfrom
IamCoder18:feat/cors-broaden-local-ip-pattern

Conversation

@IamCoder18

Copy link
Copy Markdown
Contributor

Summary

The dev-environment CORS origin check in both services previously used origin.startsWith('http://localhost:'), which rejects every other loopback/LAN address even though they are still local-only traffic. That meant requests from http://192.168.x.x, http://10.x.x.x, http://127.0.0.1, and similar local addresses all failed with standard CORS preflight errors in the browser console.

Closes #4011

The fix replaces the single prefix check with a regex that matches:

  • localhost
  • IPv4 loopback: 127.x.x.x
  • RFC1918 private ranges: 10.x.x.x, 172.16-31.x.x, 192.168.x.x
  • IPv6 local addresses: ::1, fd00::/8 ULA, fe80::/10 link-local

All with optional ports and case-insensitive scheme matching.

Files changed:

  • services/gastown/src/gastown.worker.ts
  • services/wasteland/src/wasteland.worker.ts

Verification

  • Verified locally that http://192.168.x.x origins are accepted in dev.

Visual Changes

N/A

Reviewer Notes

This regex is consistent between gastown and wasteland so the two services don't drift on what counts as "local". If we ever want to additionally allow host.docker.internal or .local mDNS names, that belongs in a follow-up change.

Comment thread services/gastown/src/gastown.worker.ts Outdated
Comment thread services/wasteland/src/wasteland.worker.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Both previously flagged regex hoisting issues are resolved; localIpPattern is now defined at module scope in both workers and the broadened CORS regex is correctly structured.

Previously Flagged Issues (now resolved)
File Line Issue Status
services/gastown/src/gastown.worker.ts 271 localIpPattern hoisted to module scope ✅ Fixed
services/wasteland/src/wasteland.worker.ts 94 localIpPattern hoisted to module scope ✅ Fixed
Files Reviewed (2 files)
  • services/gastown/src/gastown.worker.ts
  • services/wasteland/src/wasteland.worker.ts

Reviewed by claude-4.6-sonnet-20260217 · 245,888 tokens

Review guidance: REVIEW.md from base branch main

The previous localhost-only prefix check caused CORS failures when
developers accessed the dev server via LAN IP (10.x, 172.16-31.x,
192.168.x), loopback (127.x), or IPv6 link-local/ULA addresses. This
was common when using mobile devices on the same LAN for testing or
when tunneling into the dev environment.

Both gastown and wasteland were updated to use the same regex so they
stay in sync.

## Summary

- services/gastown/src/gastown.worker.ts
- services/wasteland/src/wasteland.worker.ts
@IamCoder18 IamCoder18 force-pushed the feat/cors-broaden-local-ip-pattern branch from 8eaa298 to 9c7074d Compare June 14, 2026 14:39
@IamCoder18

Copy link
Copy Markdown
Contributor Author

Ready to review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CORS errors in dev when accessing Gastown/Wasteland via LAN IP or loopback address

1 participant