Skip to content

Commit ca80b93

Browse files
committed
fix: incomplete use of basePath
1 parent b6a4311 commit ca80b93

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/app.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ export const createApp = async (): Promise<Express> => {
5050

5151
app.get('/health', (_req, res) => res.json({ status: 'ok' }))
5252

53-
app.use(tsApp)
53+
if (config.basePath) {
54+
app.use(config.basePath, tsApp)
55+
} else {
56+
app.use(tsApp)
57+
}
5458

5559
app.use((err: Error, _req: Request, res: Response, _next: NextFunction) => {
5660
log.error('unhandled request error', err)

tests/health.api.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { test, expect } from '@playwright/test'
2-
import { anonymousAx } from './support/axios.ts'
2+
import { axiosBuilder } from '@data-fair/lib-node/axios.js'
3+
4+
// Health is served at root level, not under basePath
5+
const rootAx = axiosBuilder({ baseURL: process.env.TEST_TILESERVER_URL ?? '' })
36

47
test('GET /health returns ok', async () => {
5-
const res = await anonymousAx.get('/health')
8+
const res = await rootAx.get('/health')
69
expect(res.status).toBe(200)
710
expect(res.data).toEqual({ status: 'ok' })
811
})

tests/support/axios.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { axiosBuilder } from '@data-fair/lib-node/axios.js'
22

3-
export const baseURL = process.env.TEST_TILESERVER_URL ?? ''
3+
const basePath = process.env.TEST_TILESERVER_BASE_PATH ?? '/tileserver'
4+
export const baseURL = (process.env.TEST_TILESERVER_URL ?? '') + basePath
45

56
export const anonymousAx = axiosBuilder({ baseURL })

0 commit comments

Comments
 (0)