Files
sim/.devcontainer
Waleed 0c25fc4ee1 fix(auth): resolve CORS errors for self-hosted deployments behind reverse proxies (#4369)
* fix(auth): resolve CORS errors for self-hosted deployments behind reverse proxies

- auth client now uses browser origin first, falling back to NEXT_PUBLIC_APP_URL
- socket client falls back to page origin when served from non-localhost (assumes /socket.io is proxied)
- add TRUSTED_ORIGINS env var to extend Better Auth trustedOrigins (apex+www, alias hostnames)
- warn at startup when NEXT_PUBLIC_APP_URL is localhost in production
- preprocess empty NEXT_PUBLIC_SOCKET_URL so docker-compose ${VAR:-} works
- migrate remaining uuid/nanoid/randomUUID usages to @sim/utils generateId/generateShortId
- extend generateShortId with optional alphabet param (rejection sampling)
- document TRUSTED_ORIGINS in .env.example, docker-compose.prod.yml, and helm values.yaml

Fixes simstudioai/sim#1243

* fix(auth): address PR review comments

* chore(env): drop unnecessary NEXT_PUBLIC_SOCKET_URL preprocess (skipValidation is true)

* fix(docker): include @sim/utils in migrations image

Migration scripts now import generateId from @sim/utils/id; without copying packages/utils into the image, bun install fails to resolve the workspace dep at build time and the import fails at runtime.

* fix(helm): remove unused NEXT_PUBLIC_SOCKET_URL from realtime sections

The realtime service never reads NEXT_PUBLIC_SOCKET_URL — its env schema
only includes BETTER_AUTH_URL, NEXT_PUBLIC_APP_URL, ALLOWED_ORIGINS,
BETTER_AUTH_SECRET, INTERNAL_API_SECRET, DATABASE_URL, and REDIS_URL.
Remove the dead config from all helm values files and the values schema.

* fix(helm): allow empty NEXT_PUBLIC_SOCKET_URL in values schema

The default in values.yaml is now "" (empty string), which falls back to
the page origin at runtime. The schema previously required a valid URI,
which would reject the default. Mirror the INTERNAL_API_BASE_URL pattern
using anyOf with const "". Also add TRUSTED_ORIGINS to the schema.

* docs(self-hosting): mark NEXT_PUBLIC_SOCKET_URL as optional

The page-origin fallback in getSocketUrl() means self-hosters no longer
need to set NEXT_PUBLIC_SOCKET_URL when realtime is on the same origin
as the app. Update docs to reflect this:

- Remove NEXT_PUBLIC_SOCKET_URL from .env scaffolding examples in
  docker.mdx, platforms.mdx, environment-variables.mdx
- Mark the variable as Optional in the env vars table with the new
  default behavior described
- Update troubleshooting to point at reverse-proxy /socket.io routing
  rather than the env var
- Flip dev docker-compose defaults (local, ollama, devcontainer) from
  http://localhost:3002 to empty for consistency with prod.yml; the
  in-code localhost fallback handles the dev case identically

Applied across all 6 documentation languages (en/fr/de/ja/es/zh).

* chore: untrack and ignore .claude/scheduled_tasks.lock
2026-04-30 19:26:19 -07:00
..

Sim Development Container

Development container configuration for VS Code Dev Containers and GitHub Codespaces.

Prerequisites

  • Visual Studio Code
  • Docker Desktop or Podman Desktop
  • VS Code Dev Containers extension

Getting Started

  1. Open this project in VS Code
  2. Click "Reopen in Container" when prompted (or press F1 → "Dev Containers: Reopen in Container")
  3. Wait for the container to build and initialize
  4. Start developing with sim-start

The setup script will automatically install dependencies and run migrations.

Development Commands

Running Services

You have two options for running the development environment:

Option 1: Run everything together (recommended for most development)

sim-start  # Runs both app and socket server using concurrently

Option 2: Run services separately (useful for debugging individual services)

  • In the app container terminal: sim-app (starts Next.js app on port 3000)
  • In the realtime container terminal: sim-sockets (starts socket server on port 3002)

Other Commands

  • sim-migrate - Push schema changes to the database
  • sim-generate - Generate new migrations
  • build - Build the application
  • pgc - Connect to PostgreSQL database

Troubleshooting

Build errors: Rebuild the container with F1 → "Dev Containers: Rebuild Container"

Port conflicts: Ensure ports 3000, 3002, and 5432 are available

Container runtime issues: Verify Docker Desktop or Podman Desktop is running

Technical Details

Services:

  • App container (8GB memory limit) - Main Next.js application
  • Realtime container (4GB memory limit) - Socket.io server for real-time features
  • Database - PostgreSQL with pgvector extension
  • Migrations - Runs automatically on container creation

You can develop with services running together or independently.

Personalization

Project commands (sim-start, sim-app, etc.) are automatically available via /workspace/.devcontainer/sim-commands.sh.

Personal shell customization (aliases, prompts, etc.) should use VS Code's dotfiles feature:

  1. Create a dotfiles repository (e.g., github.com/youruser/dotfiles)
  2. Add your .bashrc, .zshrc, or other configs
  3. Configure in VS Code Settings:
    {
      "dotfiles.repository": "youruser/dotfiles",
      "dotfiles.installCommand": "install.sh"
    }
    

This separates project-specific commands from personal preferences, following VS Code best practices.