API: also serve routes under /api
CI / check (push) Canceled after 0s

A reverse proxy can now forward /api/ to the API with or without stripping
the prefix (NPMplus custom locations don't strip it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
This commit is contained in:
2026-10-05 23:14:26 -04:00
co-authored by Claude Opus 5.5
parent 5c2d11384a
commit 9873cc1710
2 changed files with 21 additions and 1 deletions
+12
View File
@@ -26,6 +26,18 @@ describe('auth', () => {
expect(viaCookie.json().id).toBe(user.id);
});
it('serves the same routes under /api for proxies that keep the prefix', async () => {
const res = await app().inject({
method: 'POST',
url: '/api/auth/register',
payload: { username: 'bob', email: 'bob@example.com', password: 'password123' },
});
expect(res.statusCode).toBe(200);
const me = await app().inject({ url: '/api/me?x=1', headers: bearer(res.json().token) });
expect(me.json().username).toBe('bob');
expect((await app().inject({ url: '/apiary' })).statusCode).toBe(404);
});
it('stores only a hash of the session token', async () => {
const { token } = await createUser(app(), 'alice');
const rows = await sql`select id from sessions`;