Skip to content

Add PUBLIC_AUTH_URL and use it for generating login links #1391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ jobs:
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 }}
PUBLIC_AUTH_URL: ${{ vars.NEXT_PUBLIC_AUTH_URL }}
steps:
- uses: actions/checkout@v4
- name: Set up Node ${{ needs.get-node-version.outputs.node-version }}
Expand Down
5 changes: 3 additions & 2 deletions apps/cyberstorm-remix/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PUBLIC_SITE_URL=http://thunderstore.temp
PUBLIC_API_URL=http://thunderstore.temp
PUBLIC_SITE_URL=https://thunderstore.io
PUBLIC_API_URL=https://thunderstore.io
PUBLIC_AUTH_URL=https://auth.thunderstore.io
AUTH_ENABLED=
AUTH_SECRET=development
PUBLIC_AUTH_BASE_URL=https://auth.thunderstore.io/auth/login
Expand Down
1 change: 1 addition & 0 deletions apps/cyberstorm-remix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ yarn workspace @thunderstore/cyberstorm-remix dev --port 3000 --host 0.0.0.0
```
PUBLIC_SITE_URL=http://thunderstore.temp
PUBLIC_API_URL=http://thunderstore.temp:81
PUBLIC_AUTH_URL=http://auth.thunderstore.temp:81
```
6. Run the Nimbus project normally
1 change: 1 addition & 0 deletions apps/cyberstorm-remix/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export async function loader() {
envStuff: {
ENV: getPublicEnvVariables([
"PUBLIC_API_URL",
"PUBLIC_AUTH_URL",
"PUBLIC_CLIENT_SENTRY_DSN",
"PUBLIC_SITE_URL",
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type rootLoaderType = {
envStuff: {
ENV: {
PUBLIC_API_URL?: string;
PUBLIC_AUTH_URL?: string;
PUBLIC_CLIENT_SENTRY_DSN?: string;
PUBLIC_SITE_URL?: string;
};
Expand All @@ -20,6 +21,8 @@ export const isRootLoaderData = (obj: unknown): obj is rootLoaderType =>
isRecord(obj.root.envStuff.ENV) &&
(typeof obj.root.envStuff.ENV.PUBLIC_API_URL === "string" ||
typeof obj.root.envStuff.ENV.PUBLIC_API_URL === "undefined") &&
(typeof obj.root.envStuff.ENV.PUBLIC_AUTH_URL === "string" ||
typeof obj.root.envStuff.ENV.PUBLIC_AUTH_URL === "undefined") &&
(typeof obj.root.envStuff.ENV.PUBLIC_CLIENT_SENTRY_DSN === "string" ||
typeof obj.root.envStuff.ENV.PUBLIC_CLIENT_SENTRY_DSN === "undefined") &&
(typeof obj.root.envStuff.ENV.PUBLIC_SITE_URL === "string" ||
Expand All @@ -28,6 +31,7 @@ export const isRootLoaderData = (obj: unknown): obj is rootLoaderType =>
export type publicEnvVariablesKeys =
| "SITE_URL"
| "API_URL"
| "AUTH_URL"
| "CLIENT_SENTRY_DSN";

export type PublicPrefix<envVariable extends string> = `PUBLIC_${envVariable}`;
Expand Down
8 changes: 3 additions & 5 deletions apps/cyberstorm-remix/cyberstorm/utils/ThunderstoreAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ interface Props {
}

export function buildAuthLoginUrl(props: Props) {
const PUBLIC_API_URL = getPublicEnvVariables([
"PUBLIC_API_URL",
]).PUBLIC_API_URL;
return `${PUBLIC_API_URL}/auth/login/${props.type}/${
const envVars = getPublicEnvVariables(["PUBLIC_AUTH_URL", "PUBLIC_API_URL"]);
return `${envVars.PUBLIC_AUTH_URL}/auth/login/${props.type}/${
props.nextUrl
? `?next=${encodeURIComponent(props.nextUrl)}`
: `?next=${encodeURIComponent(`${PUBLIC_API_URL}/communities/`)}`
: `?next=${encodeURIComponent(`${envVars.PUBLIC_API_URL}/communities/`)}`
}`;
}
1 change: 1 addition & 0 deletions tools/visual-diff-ci/run_ci_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def start_frontend() -> BgProcess:
configs = {
"PUBLIC_SITE_URL": "http://127.0.0.1:8000",
"PUBLIC_API_URL": "http://127.0.0.1:8000",
"PUBLIC_AUTH_URL": "http://127.0.0.1:8000",
}
process = BgProcess(
[YARN_PATH, "workspace", "@thunderstore/cyberstorm-remix", "start", "--host", "0.0.0.0", "--port", "3000"],
Expand Down
Loading