openvibers/openvibe.ai Commits

Proxy the creation catalogue through the AI vhost (#425)

OP OpenVibers committed 3 days ago · 87b7721372 · 2 files, +20 −1

The vhost answers every unlisted /api/ path with its own 404, so /api/v1/creations and /api/v1/creations.md need their own locations. Both are public and the app sets ACAO * itself.

Changes

ddiff --git a/deploy/nginx/ai.openvibe.services.conf b/deploy/nginx/ai.openvibe.services.conf
iindex 5d24cf2..b74fc43 100644
---- a/deploy/nginx/ai.openvibe.services.conf
++++ b/deploy/nginx/ai.openvibe.services.conf
@@@ -187,6 +187,25 @@ server {
proxy_read_timeout 300s;
}
++ # ── What AI can make (ai.creation-list@1): public, cached and CORS open, for the site, an app or a
++ # page. The app answers the same ACAO * on a preflight, so OPTIONS is proxied like the GETs. ──
++ location = /api/v1/creations {
++ proxy_pass http://127.0.0.1:4700;
++ proxy_set_header Host $host;
++ proxy_set_header X-Real-IP $remote_addr;
++ proxy_set_header X-Forwarded-For $remote_addr;
++ proxy_set_header CF-Connecting-IP $remote_addr;
++ proxy_set_header X-Forwarded-Proto $scheme;
++ }
++ location = /api/v1/creations.md {
++ proxy_pass http://127.0.0.1:4700;
++ proxy_set_header Host $host;
++ proxy_set_header X-Real-IP $remote_addr;
++ proxy_set_header X-Forwarded-For $remote_addr;
++ proxy_set_header CF-Connecting-IP $remote_addr;
++ proxy_set_header X-Forwarded-Proto $scheme;
++ }
++
# ── Unknown API paths: a problem document, never a page; the API itself stays host-local ──
location /api/ {
default_type application/problem+json;
ddiff --git a/test/home.test.js b/test/home.test.js
iindex f893cf4..b03110a 100644
---- a/test/home.test.js
++++ b/test/home.test.js
@@@ -108,7 +108,7 @@ const active = (file) => fs.readFileSync(path.join(__dirname, '..', 'deploy', 'n
t.test('the vhost still proxies the API, the run receipt and the console; the app answers and redirects the pages', () => {
const conf = active('ai.openvibe.services.conf');
-- for (const loc of ['location = /stats', 'location = /updates', 'location = /terms', 'location = /privacy', 'location = /dmca', 'location = /sitemap.xml', 'location = /llms.txt', 'location /runs/ {', 'location /console {', 'location /auth/ {', 'location /shared/']) assert.ok(conf.includes(loc), loc);
++ for (const loc of ['location = /stats', 'location = /updates', 'location = /terms', 'location = /privacy', 'location = /dmca', 'location = /sitemap.xml', 'location = /llms.txt', 'location = /api/v1/creations ', 'location = /api/v1/creations.md ', 'location /runs/ {', 'location /console {', 'location /auth/ {', 'location /shared/']) assert.ok(conf.includes(loc), loc);
const ops = conf.indexOf('location ~ ^/api/v1/(chat|generate|summarize|classify|extract|embed)$ {');
const run = conf.indexOf('location ~ ^/api/v1/runs/[A-Za-z0-9_-]+$ {');
const completions = conf.indexOf('location = /v1/chat/completions {');