diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..aaa1969 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,20 @@ +ai-gateway.ldex.dev { + # 1. Force CORS headers for every request + header { + Access-Control-Allow-Origin * + Access-Control-Allow-Methods "GET, POST, OPTIONS" + Access-Control-Allow-Headers "*" + Access-Control-Expose-Headers "*" + } + + # 2. Immediately handle OPTIONS requests (the preflight) + @options { + method OPTIONS + } + handle @options { + respond "" 204 + } + + # 3. Proxy everything else to the app + reverse_proxy ai-gateway:8000 +} diff --git a/docker-compose.yml b/docker-compose.yml index 517b8a0..aeee3ce 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,34 @@ services: - api: + ai-gateway: build: . container_name: ai-gateway networks: - - caddy_network - #ports: - # - "8000:8000" + - ai_network env_file: - .env restart: always + + caddy: + image: caddy:latest + container_name: caddy + restart: always + ports: + - "80:80" + - "443:443" + - "443:443/udp" + networks: + - ai_network volumes: - - .:/app - # Override command for development/auto-reload if needed - command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload + - ./Caddyfile:/etc/caddy/Caddyfile + - caddy_data:/data + - caddy_config:/config + depends_on: + - ai-gateway networks: - caddy_network: - # Define the network at the bottom - external: true + ai_network: + driver: bridge + +volumes: + caddy_data: + caddy_config: