Skip to content

Commit 2542f4b

Browse files
committed
chore: Use dynamic base URL for API reference in main.ts
- Set base URL to localhost in dev and production URL otherwise - Construct openapi.json URL relative to base URL for flexibility - Hide download button in API reference UI for cleaner interface
1 parent 3cd3f2a commit 2542f4b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { createApiReference } from "@scalar/api-reference";
22
import "@scalar/api-reference/style.css";
33

4+
const baseUrl = import.meta.env.DEV
5+
? "http://127.0.0.1:3000"
6+
: "https://codize.dev";
7+
48
createApiReference("#app", {
5-
url: "https://codize.dev/api/v1/openapi.json",
9+
url: new URL("/api/v1/openapi.json", baseUrl).href,
610
agent: {
711
disabled: true,
812
},
913
showDeveloperTools: "never",
1014
hideClientButton: true,
1115
hideTestRequestButton: true,
16+
hideDownloadButton: true,
1217
});

0 commit comments

Comments
 (0)