listen 443 ssl http2;

include /etc/nginx/conf.d/include/ssl-settings;
include /etc/nginx/conf.d/include/init-optional-variables;

location / {
    proxy_pass http://dashboard:3000;
}

location /health {
    proxy_pass http://accounts:3000;
}

location /stripe/webhook {
    proxy_pass http://accounts:3000;
}

location /api/stripe/billing {
    proxy_pass http://dashboard:3000;
}

location /api/stripe/checkout {
    proxy_pass http://dashboard:3000;
}

location /api {
    rewrite /api/(.*) /$1 break;
    proxy_pass http://accounts:3000;
}

location /api/register {
    include /etc/nginx/conf.d/include/cors;

    rewrite /api/(.*) /$1 break;
    proxy_pass http://accounts:3000;
}

location /api/user/pubkey/register {
    include /etc/nginx/conf.d/include/cors;

    rewrite /api/(.*) /$1 break;
    proxy_pass http://accounts:3000;
}

location /api/login {
    include /etc/nginx/conf.d/include/cors;

    rewrite /api/(.*) /$1 break;
    proxy_pass http://accounts:3000;
}

location /api/logout {
    include /etc/nginx/conf.d/include/cors;

    rewrite /api/(.*) /$1 break;
    proxy_pass http://accounts:3000;
}
