# Custom nginx proxy configuration for OpenCCB
# This file configures routing for Studio (CMS) API endpoints

# Map to detect API requests that should go to port 3001
map $uri $api_backend {
    default 0;
    ~/auth/ 1;
    ~/courses/ 1;
    ~/modules/ 1;
    ~/lessons/ 1;
    ~/assets/ 1;
    ~/organization/ 1;
    ~/users/ 1;
    ~/grading/ 1;
    ~/question-bank/ 1;
    ~/test-templates/ 1;
    ~/admin/ 1;
    ~/api/ 1;
    ~/branding 1;
}

# Override upstream for API requests
map $api_backend $upstream_addr_override {
    0 "";
    1 "openccb-studio:3001";
}
