Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ jobs:
runs-on: ubuntu-latest
needs: get-node-version
env:
NEXT_PUBLIC_SITE_URL: ${{ vars.NEXT_PUBLIC_SITE_URL }}
NEXT_PUBLIC_API_URL: ${{ vars.NEXT_PUBLIC_API_URL }}
PUBLIC_SITE_URL: ${{ vars.NEXT_PUBLIC_SITE_URL }}
PUBLIC_API_URL: ${{ vars.NEXT_PUBLIC_API_URL }}
VITE_SITE_URL: ${{ vars.NEXT_PUBLIC_SITE_URL }}
VITE_API_URL: ${{ vars.NEXT_PUBLIC_API_URL }}
VITE_AUTH_BASE_URL: ${{ vars.NEXT_PUBLIC_SITE_URL }}
VITE_AUTH_RETURN_URL: ${{ vars.NEXT_PUBLIC_SITE_URL }}
steps:
- uses: actions/checkout@v4
- name: Set up Node ${{ needs.get-node-version.outputs.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/c/community.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (params.communityId) {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/communities/communities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const page = undefined;
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/dependants/Dependants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
try {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/packageEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
try {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/packageListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
try {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Comment on lines 134 to 138
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

SSR env switch is correct; add a fail-fast guard for missing VITE_API_URL

Good move to process.env for SSR. If VITE_API_URL is unset in the server env, DapperTs calls will fail later with harder-to-debug errors. Fail fast with a clear 500.

Apply this diff:

       const dapper = new DapperTs(() => {
-        return {
-          apiHost: process.env.VITE_API_URL,
-          sessionId: undefined,
-        };
+        const apiHost = process.env.VITE_API_URL;
+        if (!apiHost) {
+          // Avoid obscure downstream failures when env is misconfigured
+          throw new Response("Server misconfiguration: VITE_API_URL is not set", { status: 500 });
+        }
+        return {
+          apiHost,
+          sessionId: undefined,
+        };
       });

Verification helper to catch any remaining SSR usages of import.meta.env and spot loaders missing the guard:


🏁 Script executed:

#!/bin/bash
# 1) Find SSR-ish contexts (loaders, server utils) that still reference import.meta.env
rg -n -C2 'import\.meta\.env\.' apps/cyberstorm-remix/app

# 2) Review all DapperTs server initializations and ensure a guard exists
rg -n -C2 '(new DapperTs\(|DapperTs\()\s*=>\s*\{' apps/cyberstorm-remix/app | rg -n -C1 'apiHost: '

Length of output: 4801


🏁 Script executed:

#!/bin/bash
# List all DapperTs initializations across the codebase
rg -n -C3 'new DapperTs' apps/cyberstorm-remix/app || true

# Also find any direct DapperTs calls without 'new'
rg -n -C3 '\bDapperTs\(' apps/cyberstorm-remix/app || true

Length of output: 47761


Add fail-fast guard for missing VITE_API_URL across all SSR loaders

When apiHost is sourced directly from process.env.VITE_API_URL, a missing env var will only surface as obscure downstream errors. Failing fast with a clear 500 prevents hard-to-debug issues.

Apply this diff (or extract into a shared getServerConfig() helper) at each loader/DapperTs initialization that currently uses process.env.VITE_API_URL:

- const dapper = new DapperTs(() => ({
-   apiHost: process.env.VITE_API_URL,
-   sessionId: undefined,
- }));
+ const dapper = new DapperTs(() => {
+   const apiHost = process.env.VITE_API_URL;
+   if (!apiHost) {
+     throw new Response(
+       "Server misconfiguration: VITE_API_URL is not set",
+       { status: 500 }
+     );
+   }
+   return {
+     apiHost,
+     sessionId: undefined,
+   };
+ });

Locations requiring this update:

  • apps/cyberstorm-remix/app/upload/upload.tsx (loader)
  • apps/cyberstorm-remix/app/p/packageListing.tsx (loader)
  • apps/cyberstorm-remix/app/p/packageEdit.tsx (loader)
  • apps/cyberstorm-remix/app/p/dependants/Dependants.tsx (loader)
  • apps/cyberstorm-remix/app/p/tabs/Wiki/WikiPage.tsx (loader)
  • apps/cyberstorm-remix/app/p/tabs/Wiki/WikiFirstPage.tsx (loader)
  • apps/cyberstorm-remix/app/p/tabs/Wiki/Wiki.tsx (loader)
  • apps/cyberstorm-remix/app/p/tabs/Required/Required.tsx (loader)
  • apps/cyberstorm-remix/app/p/tabs/Versions/Versions.tsx (loader)
  • apps/cyberstorm-remix/app/communities/communities.tsx (loader)
  • apps/cyberstorm-remix/app/c/community.tsx (loader)
  • apps/cyberstorm-remix/app/p/team/Team.tsx (loader)
  • apps/cyberstorm-remix/app/p/tabs/Readme/Readme.tsx (loader)
  • apps/cyberstorm-remix/app/p/tabs/Changelog/Changelog.tsx (loader)

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In apps/cyberstorm-remix/app/p/packageListing.tsx around lines 134-138, the
loader returns apiHost directly from process.env.VITE_API_URL which will cause
obscure downstream errors if unset; add a fail-fast guard that checks
process.env.VITE_API_URL and throws a 500 Response (or otherwise return a server
error) with a clear message like "Missing VITE_API_URL" when it's missing, and
replace direct env access with a small shared getServerConfig() helper (used by
all listed loaders) that validates the env, returns { apiHost, sessionId } when
present, and throws the 500 Response when not.

Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/tabs/Changelog/Changelog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
try {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Comment on lines 10 to 15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Validate presence of VITE_API_URL in SSR

Ensure the server env is configured; otherwise return a 500 with a clear message.

-      const dapper = new DapperTs(() => {
-        return {
-          apiHost: process.env.VITE_API_URL,
-          sessionId: undefined,
-        };
-      });
+      const apiHost = process.env.VITE_API_URL;
+      if (!apiHost) {
+        throw new Response("API host is not configured (VITE_API_URL missing)", { status: 500 });
+      }
+      const dapper = new DapperTs(() => ({
+        apiHost,
+        sessionId: undefined,
+      }));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
const apiHost = process.env.VITE_API_URL;
if (!apiHost) {
throw new Response("API host is not configured (VITE_API_URL missing)", { status: 500 });
}
const dapper = new DapperTs(() => ({
apiHost,
sessionId: undefined,
}));
🤖 Prompt for AI Agents
In apps/cyberstorm-remix/app/p/tabs/Changelog/Changelog.tsx around lines 10-15,
ensure the server-side environment variable VITE_API_URL is present before
constructing DapperTs; if running in SSR (typeof window === 'undefined') and
process.env.VITE_API_URL is missing, immediately return/throw a 500 Response
with a clear message like "VITE_API_URL not configured" (or use Remix's
json/Response helpers), otherwise pass the validated apiHost into DapperTs; this
prevents creating the client with an undefined host and yields a proper 500
error when the server is misconfigured.

Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/tabs/Readme/Readme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
try {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Comment on lines 10 to 15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Harden env var usage: validate and normalize VITE_API_URL before passing to DapperTs

process.env values are string | undefined. If VITE_API_URL is missing, DapperTs will receive undefined and fail later. Fail fast with a clear error and normalize trailing slashes to avoid accidental double slashes in requests.

Apply this diff:

-      const dapper = new DapperTs(() => {
-        return {
-          apiHost: process.env.VITE_API_URL,
-          sessionId: undefined,
-        };
-      });
+      const rawApiHost = process.env.VITE_API_URL ?? "";
+      if (!rawApiHost) {
+        throw new Error("VITE_API_URL is not set in the server environment (SSR loader: Readme).");
+      }
+      const apiHost = rawApiHost.replace(/\/+$/, "");
+      const dapper = new DapperTs(() => ({
+        apiHost,
+        sessionId: undefined,
+      }));

Optional repo-wide verification to ensure no server loader still relies on import.meta.env for apiHost:


🏁 Script executed:

#!/bin/bash
# Verify all server loaders use process.env for DapperTs apiHost
rg -nP --type=ts --type=tsx -C2 'new\s+DapperTs\s*\(\s*\(\)\s*=>\s*{\s*return\s*{\s*[^}]*apiHost:' apps/cyberstorm-remix | sed 's/^/HIT: /'
echo "---- Leftovers using import.meta.env.VITE_API_URL ----"
rg -n 'import\.meta\.env\.VITE_API_URL' apps/cyberstorm-remix || true

Length of output: 669


Ensure all DapperTs apiHost usages validate and normalize VITE_API_URL

Your app still has a few places where import.meta.env.VITE_API_URL is used directly. Those need the same “fail-fast” validation and trailing-slash normalization you applied in the SSR loader. Specifically:

• In apps/cyberstorm-remix/app/middlewares.ts
– Line 12: getSessionContext(import.meta.env.VITE_API_URL)
– Line 17: const session = getSessionContext(import.meta.env.VITE_API_URL);

• In apps/cyberstorm-remix/app/entry.client.tsx
– Line 12 (commented example):
ts // apiHost: import.meta.env.VITE_API_URL ?? "MISSING_API_HOST",

Please refactor these to mirror the pattern in Readme.tsx:

- import.meta.env.VITE_API_URL
+ (() => {
+   const rawApiHost = process.env.VITE_API_URL ?? "";
+   if (!rawApiHost) {
+     throw new Error(
+       "VITE_API_URL must be set in the environment (middleware/session loader)."
+     );
+   }
+   return rawApiHost.replace(/\/+$/, "");
+ })()

For example, in middlewares.ts:

- const session = getSessionContext(import.meta.env.VITE_API_URL);
+ const rawApiHost = process.env.VITE_API_URL ?? "";
+ if (!rawApiHost) {
+   throw new Error(
+     "VITE_API_URL is required for session context (middlewares.ts)."
+   );
+ }
+ const apiHost = rawApiHost.replace(/\/+$/, "");
+ const session = getSessionContext(apiHost);

And update the client entry snippet similarly to ensure consistency across all loaders and entrypoints.

🤖 Prompt for AI Agents
In apps/cyberstorm-remix/app/p/tabs/Readme/Readme.tsx around lines 10 to 15, and
related usages in apps/cyberstorm-remix/app/middlewares.ts (lines ~12 and ~17)
and apps/cyberstorm-remix/app/entry.client.tsx (line ~12 commented snippet), the
code uses import.meta.env.VITE_API_URL directly; replicate the Readme.tsx
pattern by centralizing validation/normalization of VITE_API_URL
(throwing/console.error if missing), ensure the returned apiHost has a trailing
slash normalized, and pass that normalized value into DapperTs/getSessionContext
and into the client entry snippet so all entrypoints fail-fast and use the same
normalized host string.

Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/tabs/Required/Required.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
try {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/tabs/Versions/Versions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
try {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Comment on lines 33 to 38
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Guard against missing VITE_API_URL in SSR loader

process.env.VITE_API_URL can be undefined at runtime, causing DapperTs to be configured with an invalid host. Add an explicit invariant with a clear 500 to avoid confusing downstream failures.

-      const dapper = new DapperTs(() => {
-        return {
-          apiHost: process.env.VITE_API_URL,
-          sessionId: undefined,
-        };
-      });
+      const apiHost = process.env.VITE_API_URL;
+      if (!apiHost) {
+        throw new Response("API host is not configured (VITE_API_URL missing)", { status: 500 });
+      }
+      const dapper = new DapperTs(() => ({
+        apiHost,
+        sessionId: undefined,
+      }));

To scan the repo for other unguarded usages and review them quickly, run:


🏁 Script executed:

#!/bin/bash
# Find all SSR loaders using process.env.VITE_API_URL without a guard nearby
rg -n --type=ts --type=tsx 'process\.env\.VITE_API_URL' -C2

Length of output: 89


🏁 Script executed:

#!/bin/bash
# Find all occurrences of VITE_API_URL in TS/TSX files with context
rg -n 'process\.env\.VITE_API_URL' -g '*.ts' -g '*.tsx' -C2

Length of output: 6218


Guard against missing VITE_API_URL in all SSR loaders

We found 15 unguarded initializations of DapperTs using process.env.VITE_API_URL. If the env var is undefined at runtime, downstream calls will fail in confusing, non-HTTP-friendly ways. Please centralize and enforce a guard so any missing configuration immediately surfaces as a 500 response.

• Files (unguarded apiHost: process.env.VITE_API_URL at these lines):

  • apps/cyberstorm-remix/app/c/community.tsx:66
  • apps/cyberstorm-remix/app/communities/communities.tsx:71
  • apps/cyberstorm-remix/app/p/dependants/Dependants.tsx:30
  • apps/cyberstorm-remix/app/p/tabs/Wiki/Wiki.tsx:16
  • apps/cyberstorm-remix/app/p/tabs/Wiki/WikiPage.tsx:18
  • apps/cyberstorm-remix/app/p/tabs/Wiki/WikiPageEdit.tsx:43
  • apps/cyberstorm-remix/app/p/tabs/Versions/Versions.tsx:35
  • apps/cyberstorm-remix/app/p/tabs/Required/Required.tsx:16
  • apps/cyberstorm-remix/app/p/tabs/Wiki/WikiFirstPage.tsx:13
  • apps/cyberstorm-remix/app/p/tabs/Changelog/Changelog.tsx:12
  • apps/cyberstorm-remix/app/p/tabs/Readme/Readme.tsx:12
  • apps/cyberstorm-remix/app/upload/upload.tsx:73
  • apps/cyberstorm-remix/app/p/packageEdit.tsx:47
  • apps/cyberstorm-remix/app/p/team/Team.tsx:25
  • apps/cyberstorm-remix/app/p/packageListing.tsx:135

Suggested essential refactor

  1. Create a shared helper (e.g. app/utils/getApiHost.ts):
export function getApiHost(): string {
  const host = process.env.VITE_API_URL;
  if (!host) {
    throw new Response(
      "API host is not configured (VITE_API_URL missing)",
      { status: 500 }
    );
  }
  return host;
}
  1. Update each loader:
-import { DapperTs } from "dapper-ts";
-const dapper = new DapperTs(() => ({
-  apiHost: process.env.VITE_API_URL,
-  sessionId: undefined,
-}));
+import { DapperTs } from "dapper-ts";
+import { getApiHost } from "~/utils/getApiHost";
+const dapper = new DapperTs(() => ({
+  apiHost: getApiHost(),
+  sessionId: undefined,
+}));

This ensures every SSR loader fails fast with a clear 500 if the API URL isn’t set.

🤖 Prompt for AI Agents
In apps/cyberstorm-remix/app/p/tabs/Versions/Versions.tsx around lines 33 to 38,
the DapperTs initialization uses process.env.VITE_API_URL directly which can be
undefined at runtime; create a shared helper (e.g. app/utils/getApiHost.ts) that
reads process.env.VITE_API_URL and throws a Response with status 500 if missing,
then replace direct uses of process.env.VITE_API_URL in this file (and the other
listed SSR loader files) by calling getApiHost() and passing its returned string
into new DapperTs so missing configuration fails fast with a clear 500 response.

Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/tabs/Wiki/Wiki.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
if (params.communityId && params.namespaceId && params.packageId) {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/tabs/Wiki/WikiFirstPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
if (params.communityId && params.namespaceId && params.packageId) {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Comment on lines 11 to 16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add an SSR env invariant for VITE_API_URL

Keep the pattern consistent and fail fast if the host is not configured.

-    const dapper = new DapperTs(() => {
-      return {
-        apiHost: process.env.VITE_API_URL,
-        sessionId: undefined,
-      };
-    });
+    const apiHost = process.env.VITE_API_URL;
+    if (!apiHost) {
+      throw new Response("API host is not configured (VITE_API_URL missing)", { status: 500 });
+    }
+    const dapper = new DapperTs(() => ({
+      apiHost,
+      sessionId: undefined,
+    }));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
const apiHost = process.env.VITE_API_URL;
if (!apiHost) {
throw new Response("API host is not configured (VITE_API_URL missing)", { status: 500 });
}
const dapper = new DapperTs(() => ({
apiHost,
sessionId: undefined,
}));
🤖 Prompt for AI Agents
In apps/cyberstorm-remix/app/p/tabs/Wiki/WikiFirstPage.tsx around lines 11-16,
add a server-side invariant check that process.env.VITE_API_URL is present
before constructing DapperTs and fail fast if missing; implement by reading
process.env.VITE_API_URL into a const at module/runtime start, throw a clear
Error (or use the project's invariant helper) when it's undefined/empty, then
pass that const into the DapperTs config instead of accessing process.env
directly.

Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/tabs/Wiki/WikiPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
) {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Comment on lines 16 to 21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

SSR env guard for VITE_API_URL

Same as other loaders; add a clear failure mode when env is missing.

-    const dapper = new DapperTs(() => {
-      return {
-        apiHost: process.env.VITE_API_URL,
-        sessionId: undefined,
-      };
-    });
+    const apiHost = process.env.VITE_API_URL;
+    if (!apiHost) {
+      throw new Response("API host is not configured (VITE_API_URL missing)", { status: 500 });
+    }
+    const dapper = new DapperTs(() => ({
+      apiHost,
+      sessionId: undefined,
+    }));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
const apiHost = process.env.VITE_API_URL;
if (!apiHost) {
throw new Response(
"API host is not configured (VITE_API_URL missing)",
{ status: 500 }
);
}
const dapper = new DapperTs(() => ({
apiHost,
sessionId: undefined,
}));
🤖 Prompt for AI Agents
In apps/cyberstorm-remix/app/p/tabs/Wiki/WikiPage.tsx around lines 16 to 21, the
DapperTs initializer reads process.env.VITE_API_URL without guarding for
SSR/missing env; add an explicit runtime check that throws a clear error (or
uses an invariant) if VITE_API_URL is undefined/empty, and then pass the
validated URL into apiHost so the app fails fast with a helpful message on SSR
when the env is not provided.

Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/tabs/Wiki/WikiPageEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
) {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/p/team/Team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
try {
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Comment on lines 23 to 28
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

SSR env may be undefined — validate VITE_API_URL before constructing DapperTs

Same reasoning as other loaders; fail fast with a clear error if env is missing.

-      const dapper = new DapperTs(() => {
-        return {
-          apiHost: process.env.VITE_API_URL,
-          sessionId: undefined,
-        };
-      });
+      const apiHost = process.env.VITE_API_URL;
+      if (!apiHost) {
+        throw new Response("API host is not configured (VITE_API_URL missing)", { status: 500 });
+      }
+      const dapper = new DapperTs(() => ({
+        apiHost,
+        sessionId: undefined,
+      }));

Validate VITE_API_URL at runtime before instantiating DapperTs

VITE-prefixed env variables are only exposed as strings via import.meta.env and will be undefined if not set (vitejs.dev). Remix’s built-in dotenv support only applies in remix dev—it does not load .env in production, so process.env.VITE_API_URL can also be undefined at runtime unless your deployment explicitly supplies it (remix.run).

• File: apps/cyberstorm-remix/app/p/team/Team.tsx
Lines: ~23–28

Please update this block to extract and validate the API host, failing fast with a clear 500 error if it’s missing:

-      const dapper = new DapperTs(() => {
-        return {
-          apiHost: process.env.VITE_API_URL,
-          sessionId: undefined,
-        };
-      });
+      const apiHost = process.env.VITE_API_URL;
+      if (!apiHost) {
+        throw new Response(
+          "API host is not configured (VITE_API_URL missing)",
+          { status: 500 }
+        );
+      }
+      const dapper = new DapperTs(() => ({
+        apiHost,
+        sessionId: undefined,
+      }));
🤖 Prompt for AI Agents
In apps/cyberstorm-remix/app/p/team/Team.tsx around lines 23–28, don't read
process.env directly into DapperTs; first extract the API host from
import.meta.env.VITE_API_URL (with an optional fallback to
process.env.VITE_API_URL), validate it is a non-empty string, and only then
instantiate DapperTs. If the value is missing or empty, fail fast by throwing a
clear 500 Response (e.g. throw new Response('VITE_API_URL is not set', { status:
500 })) so the app surfaces a clear error rather than silently passing undefined
into DapperTs.

Expand Down
14 changes: 12 additions & 2 deletions apps/cyberstorm-remix/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ const adContainerIds = ["right-column-1", "right-column-2", "right-column-3"];
export function Layout({ children }: { children: React.ReactNode }) {
const data = useRouteLoaderData<RootClientLoader>("root");

const domain = import.meta.env.VITE_SITE_URL ?? "https://thunderstore.io";
let domain: string;
if (import.meta.env.SSR) {
domain = process.env.VITE_SITE_URL || "";
} else {
domain = import.meta.env.VITE_SITE_URL;
}

const location = useLocation();
const shouldShowAds = location.pathname.startsWith("/teams")
Expand Down Expand Up @@ -197,7 +202,12 @@ const TooltipProvider = memo(function TooltipProvider({

function App() {
// TODO: Remove this customization when legacy site is removed
const domain = import.meta.env.VITE_SITE_URL ?? "https://thunderstore.io";
let domain: string;
if (import.meta.env.SSR) {
domain = process.env.VITE_SITE_URL || "";
} else {
domain = import.meta.env.VITE_SITE_URL;
}

const data = useRouteLoaderData<typeof clientLoader>("root");
const dapper = new DapperTs(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/cyberstorm-remix/app/upload/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function loader() {
// console.log("loader context", getSessionTools(context));
const dapper = new DapperTs(() => {
return {
apiHost: import.meta.env.VITE_API_URL,
apiHost: process.env.VITE_API_URL,
sessionId: undefined,
};
});
Expand Down
16 changes: 12 additions & 4 deletions apps/cyberstorm-remix/cyberstorm/utils/ThunderstoreAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ interface Props {
}

export function buildAuthLoginUrl(props: Props) {
return `${import.meta.env.VITE_AUTH_BASE_URL}/auth/login/${props.type}/${
let domain: string;
let returnDomain: string;
if (import.meta.env.SSR) {
domain = process.env.VITE_SITE_URL || "";
returnDomain = process.env.VITE_AUTH_RETURN_URL || "";
} else {
domain = import.meta.env.VITE_SITE_URL;
returnDomain = import.meta.env.VITE_AUTH_RETURN_URL;
}

return `${domain}/auth/login/${props.type}/${
props.nextUrl
? `?next=${encodeURIComponent(props.nextUrl)}`
: `?next=${encodeURIComponent(
`${import.meta.env.VITE_AUTH_RETURN_URL}/communities/`
)}`
: `?next=${encodeURIComponent(`${returnDomain}/communities/`)}`
}`;
}
5 changes: 2 additions & 3 deletions apps/cyberstorm-storybook/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const API_DOMAIN =
process.env.NEXT_PUBLIC_API_URL || "https://thunderstore.io";
export const API_DOMAIN = process.env.VITE_API_URL || "https://thunderstore.io";

export const ROOT_DOMAIN =
process.env.NEXT_PUBLIC_SITE_URL || "https://thunderstore.io";
process.env.VITE_SITE_URL || "https://thunderstore.io";
6 changes: 4 additions & 2 deletions tools/visual-diff-ci/run_ci_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ def setup_frontend():

def start_frontend() -> BgProcess:
configs = {
"PUBLIC_SITE_URL": "http://127.0.0.1:8000",
"PUBLIC_API_URL": "http://127.0.0.1:8000",
"VITE_SITE_URL": "http://127.0.0.1:8000",
"VITE_API_URL": "http://127.0.0.1:8000",
"VITE_AUTH_BASE_URL": "http://127.0.0.1:8000",
"VITE_AUTH_RETURN_URL": "http://127.0.0.1:8000",
}
Comment on lines +140 to 144
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify SITE/RETURN URL ports (likely 3000) vs API/AUTH_BASE (8000) to avoid redirect/domain mismatches

The dev server is started on port 3000 (Line 146), but VITE_SITE_URL and VITE_AUTH_RETURN_URL are set to 8000. If auth flows construct return URLs using these, the browser may be redirected to 8000 instead of the frontend (3000). Consider mapping:

  • VITE_API_URL, VITE_AUTH_BASE_URL → 8000 (backend)
  • VITE_SITE_URL, VITE_AUTH_RETURN_URL → 3000 (frontend)

Apply if appropriate:

-        "VITE_SITE_URL": "http://127.0.0.1:8000",
-        "VITE_API_URL": "http://127.0.0.1:8000",
-        "VITE_AUTH_BASE_URL": "http://127.0.0.1:8000",
-        "VITE_AUTH_RETURN_URL": "http://127.0.0.1:8000",
+        "VITE_SITE_URL": "http://127.0.0.1:3000",
+        "VITE_API_URL": "http://127.0.0.1:8000",
+        "VITE_AUTH_BASE_URL": "http://127.0.0.1:8000",
+        "VITE_AUTH_RETURN_URL": "http://127.0.0.1:3000",

To quickly confirm port usage and return URL construction hotspots:


🏁 Script executed:

#!/bin/bash
# Frontend dev server port
rg -nC2 'workspace", "@thunderstore/cyberstorm-remix", "start".*--port", "3000' tools/visual-diff-ci/run_ci_script.py

# Places building login/return URLs or using these envs
rg -n --type=ts --type=tsx 'VITE_(SITE_URL|AUTH_RETURN_URL|AUTH_BASE_URL|API_URL)'

Length of output: 443


🏁 Script executed:

#!/bin/bash
# Confirm frontend dev server port usage
rg -nC2 '--port", "3000' tools/visual-diff-ci/run_ci_script.py

# Show the environment configuration block
rg -n 'configs\s*=\s*{' -C5 tools/visual-diff-ci/run_ci_script.py

Length of output: 643


Fix frontend URL ports to match the dev server

The CI script launches the frontend on port 3000 (BgProcess at line 146), but both VITE_SITE_URL and VITE_AUTH_RETURN_URL are still pointing to port 8000. This will cause auth redirects to hit the backend instead of your running frontend. Please update the env block in tools/visual-diff-ci/run_ci_script.py:

• File: tools/visual-diff-ci/run_ci_script.py
Lines: ~140–144

-        "VITE_SITE_URL": "http://127.0.0.1:8000",
-        "VITE_AUTH_RETURN_URL": "http://127.0.0.1:8000",
+        "VITE_SITE_URL":        "http://127.0.0.1:3000",
+        "VITE_AUTH_RETURN_URL": "http://127.0.0.1:3000",

Leave the API-related URLs on port 8000:

         "VITE_API_URL":        "http://127.0.0.1:8000",
         "VITE_AUTH_BASE_URL":  "http://127.0.0.1:8000",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"VITE_SITE_URL": "http://127.0.0.1:8000",
"VITE_API_URL": "http://127.0.0.1:8000",
"VITE_AUTH_BASE_URL": "http://127.0.0.1:8000",
"VITE_AUTH_RETURN_URL": "http://127.0.0.1:8000",
}
"VITE_SITE_URL": "http://127.0.0.1:3000",
"VITE_API_URL": "http://127.0.0.1:8000",
"VITE_AUTH_BASE_URL": "http://127.0.0.1:8000",
"VITE_AUTH_RETURN_URL": "http://127.0.0.1:3000",
}
🤖 Prompt for AI Agents
In tools/visual-diff-ci/run_ci_script.py around lines 140 to 144, the env dict
sets VITE_SITE_URL and VITE_AUTH_RETURN_URL to port 8000 while the frontend is
started on port 3000 (BgProcess at ~line 146); update VITE_SITE_URL and
VITE_AUTH_RETURN_URL to use http://127.0.0.1:3000 so auth redirects go to the
running frontend, and keep VITE_API_URL and VITE_AUTH_BASE_URL pointing at port
8000 unchanged.

process = BgProcess(
[YARN_PATH, "workspace", "@thunderstore/cyberstorm-remix", "start", "--host", "0.0.0.0", "--port", "3000"],
Expand Down
Loading