Skip to content

Commit 78d9035

Browse files
committed
add basePath Swagger option
1 parent 071eb85 commit 78d9035

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ This is the complete complete list of environmental variables that can be set.
4747
| SERVER_LOGGER_PATH | No | undefined | Log to file instead of console, ex: `/path/to/file` |
4848
| SERVER_HOST | No | 0.0.0.0 | IP to [listen](https://www.fastify.io/docs/latest/Reference/Server/#listen) on, default is all |
4949
| SERVER_PORT | No | 3000 | Port to [listen](https://www.fastify.io/docs/latest/Reference/Server/#listen) on |
50+
| BASE_PATH | No | / | The [base path](https://swagger.io/specification/v2/) on which the API is served, which is relative to the host |
5051
| CACHE_PRIVACY | No | private | [Cache response directive](https://github.com/fastify/fastify-caching) |
5152
| CACHE_EXPIRESIN | No | 3600 | [Max age in seconds](https://github.com/fastify/fastify-caching) |
5253
| CACHE_SERVERCACHE | No | undefined | Max age in seconds for [shared cache](https://github.com/fastify/fastify-caching) (i.e. CDN) |

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ fastify.register(require('@fastify/swagger'), {
5555
routePrefix: '/',
5656
hideUntagged: true,
5757
swagger: {
58+
"basePath": process.env.BASE_PATH || "/",
5859
"info": {
5960
"title": "Dirt-Simple PostGIS HTTP API",
6061
"description": "The Dirt-Simple PostGIS HTTP API is an easy way to expose geospatial functionality to your applications. It takes simple requests over HTTP and returns JSON, JSONP, or protobuf (Mapbox Vector Tile) to the requester. Although the focus of the project has generally been on exposing PostGIS functionality to web apps, you can use the framework to make an API to any database.",

0 commit comments

Comments
 (0)