diff --git a/src/main/resources/swagger/index.html b/src/main/resources/swagger/index.html
index 44630b91f99a6f74e84dce414c1caa9f7dfdee8c..a1c3c76a4d93b88a522dbf5060ca00b4bebbf947 100644
--- a/src/main/resources/swagger/index.html
+++ b/src/main/resources/swagger/index.html
@@ -11,13 +11,16 @@
 
   <script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
   <script>
+    let pathname = window.location.pathname;
+    pathname = pathname == "/" ? "" : pathname;
+
     SwaggerUIBundle({
-        url: "./swagger/netcdf-services.yml",
+        url: `${pathname}/swagger/netcdf-services.yml`,
         dom_id: '#swagger-ui',
         presets: [
           SwaggerUIBundle.presets.apis
         ]
-    })
+    });
   </script>
 </body>
 </html>