We are migrating off an old api onto a new api. We will eventually update the front end code but for now are doing it in nginx.
#location /vapi {
# old api
location ~ ^/vapi/(?!(sites))/.+$ {
add_header Access-Control-Allow-Origin $cors_header;
access_log logs/vapi.proxy.log lfupstream;
error_log logs/vapi.error.log error;
rewrite ^/vapi/(.*)$ /$1 break;
proxy_pass http://vapi;
}
# new api
location ~ ^/vapi/sites/.+$ {
add_header Access-Control-Allow-Origin $cors_header;
access_log logs/vapi.portal.proxy.log lfupstream;
error_log logs/vapi.portal.error.log error;
rewrite ^(.*)$ /api/$1 break;
proxy_pass https://portal;
}
The old api is matching https://exa.valor.network/vapi/sites/SITE-NAME
Have also tried:
location /vapi {
...
}
location /vapi/sites {
...
}
and
location /vapi {
...
}
location ~^/vapi/sites/.+$ {
...
}
Ref: Nginx location "not equal to" regex Ref: Nginx location priority