diff --git a/server/swagger/init.js b/server/swagger/init.js
index c84daf3231d8ebd50d3e3cae04075222971963f6..b68e3249ce92d32c978acd26f80f6e773a16e2b1 100644
--- a/server/swagger/init.js
+++ b/server/swagger/init.js
@@ -1,4 +1,6 @@
 const swaggerAutogen = require('swagger-autogen')({ openapi: '3.0.0' });
+const fs = require('fs')
+const path = require('path')
 
 const doc = {
   info: {
@@ -6,6 +8,8 @@ const doc = {
     title: 'AnythingLLM Developer API',
     description: 'API endpoints that enable programmatic reading, writing, and updating of your AnythingLLM instance. UI supplied by Swagger.io.',
   },
+  // Swagger-autogen does not allow us to use relative paths as these will resolve to
+  // http:///api in the openapi.json file, so we need to monkey-patch this post-generation.
   host: '/api',
   schemes: ['http'],
   securityDefinitions: {
@@ -25,7 +29,7 @@ const doc = {
   }
 };
 
-const outputFile = './openapi.json';
+const outputFile = path.resolve(__dirname, './openapi.json');
 const endpointsFiles = [
   '../endpoints/api/auth/index.js',
   '../endpoints/api/admin/index.js',
@@ -34,4 +38,14 @@ const endpointsFiles = [
   '../endpoints/api/system/index.js',
 ];
 
-swaggerAutogen(outputFile, endpointsFiles, doc)
\ No newline at end of file
+swaggerAutogen(outputFile, endpointsFiles, doc)
+  .then(({ data }) => {
+    const openApiSpec = {
+      ...data,
+      servers: [{
+        url: "/api"
+      }]
+    }
+    fs.writeFileSync(outputFile, JSON.stringify(openApiSpec, null, 2), { encoding: 'utf-8', flag: 'w' });
+    console.log(`Swagger-autogen:  \x1b[32mPatched servers.url ✔\x1b[0m`)
+  })
\ No newline at end of file
diff --git a/server/swagger/openapi.json b/server/swagger/openapi.json
index cb065522efe93b3b5798e6ac3fcf6bc88efa49eb..184723ed7e53611211e7d06bfb1ecb1e867375a8 100644
--- a/server/swagger/openapi.json
+++ b/server/swagger/openapi.json
@@ -7,7 +7,7 @@
   },
   "servers": [
     {
-      "url": "http:///api/"
+      "url": "/api"
     }
   ],
   "paths": {