Skip to content

Commit

Permalink
Fixing docs definition retrieval logic to use proper environment vari…
Browse files Browse the repository at this point in the history
…ables (#2053)
  • Loading branch information
dubwub authored Jan 22, 2025
1 parent d482114 commit 4ff17d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/fern-docs/bundle/src/server/DocsLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,19 @@ export class DocsLoader {
.load();
}

private getDocsDefinitionUrl() {
return (
process.env.NEXT_PUBLIC_DOCS_DEFINITION_S3_URL ??
"https://docs-definitions.buildwithfern.com"
);
}

private async loadDocs(): Promise<
DocsV2Read.LoadDocsForUrlResponse | undefined
> {
if (!this.#loadForDocsUrlResponse) {
try {
const environmentType = process.env.NODE_ENV ?? "development";
let dbDocsDefUrl = "";
if (environmentType === "development") {
dbDocsDefUrl = `https://docs-definitions-dev2.buildwithfern.com/${this.domain}.json`;
} else if (environmentType === "production") {
dbDocsDefUrl = `https://docs-definitions.buildwithfern.com/${this.domain}.json`;
}
const dbDocsDefUrl = `${this.getDocsDefinitionUrl()}/${this.domain}.json`;
const response = await fetch(dbDocsDefUrl);
if (response.ok) {
const json = await response.json();
Expand Down
1 change: 1 addition & 0 deletions packages/fern-docs/bundle/turbo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"globalEnv": ["FERN_ENVIRONMENT", "APPLICATION_ENVIRONMENT"],
"tasks": {
"docs:build": {
"outputs": [".next/**", "!.next/cache/**"],
Expand Down

0 comments on commit 4ff17d6

Please sign in to comment.