Merged Caddy into docker-compose and added edge CORS handling
This commit is contained in:
20
Caddyfile
Normal file
20
Caddyfile
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -1,20 +1,34 @@
|
|||||||
services:
|
services:
|
||||||
api:
|
ai-gateway:
|
||||||
build: .
|
build: .
|
||||||
container_name: ai-gateway
|
container_name: ai-gateway
|
||||||
networks:
|
networks:
|
||||||
- caddy_network
|
- ai_network
|
||||||
#ports:
|
|
||||||
# - "8000:8000"
|
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
|
caddy:
|
||||||
|
image: caddy:latest
|
||||||
|
container_name: caddy
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
- "443:443/udp"
|
||||||
|
networks:
|
||||||
|
- ai_network
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- ./Caddyfile:/etc/caddy/Caddyfile
|
||||||
# Override command for development/auto-reload if needed
|
- caddy_data:/data
|
||||||
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
|
- caddy_config:/config
|
||||||
|
depends_on:
|
||||||
|
- ai-gateway
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
caddy_network:
|
ai_network:
|
||||||
# Define the network at the bottom
|
driver: bridge
|
||||||
external: true
|
|
||||||
|
volumes:
|
||||||
|
caddy_data:
|
||||||
|
caddy_config:
|
||||||
|
|||||||
Reference in New Issue
Block a user