Skip to content

Commit

Permalink
fix: fix env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Rei-x committed Jan 6, 2024
1 parent 8d015e6 commit e654d93
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DIRECTUS_URL="https://directus.universe.nexus"
NEXT_PUBLIC_DIRECTUS_URL="https://directus.universe.nexus"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup env
run: |
touch .env
echo DIRECTUS_URL="https://directus.universe.nexus" > .env
echo NEXT_PUBLIC_DIRECTUS_URL="https://directus.universe.nexus" > .env
- name: Install
run: npm ci
- name: Cache build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
- name: Build frontend
run: |
touch .env
echo DIRECTUS_URL="https://directus.universe.nexus" >> .env
echo NEXT_PUBLIC_DIRECTUS_URL="https://directus.universe.nexus" >> .env
npm run build
- name: Starting app
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Pozwoli na wyszukiwanie organizacji studenckich i koł naukowych po słowach klu

### Zmienne środowiskowe

- `DIRECTUS_URL` - adres do instancji Directusa
- `NEXT_PUBLIC_DIRECTUS_URL` - adres do instancji Directusa

### Wymagania

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"build": "next build",
"dev": "next dev",
"generate": "npm run setupEnv -- npx zeus $DIRECTUS_URL ./src/utils/",
"generate": "npm run setupEnv -- npx zeus $NEXT_PUBLIC_DIRECTUS_URL ./src/utils/",
"lint": "npm run setupEnv -- next lint",
"format:check": "prettier --check src",
"format:fix": "prettier --write src",
Expand Down
4 changes: 2 additions & 2 deletions scripts/loadDataToDirectus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const findFilename = (filename: string, filenames: string[]) => {
};

const CONFIG = {
DIRECTUS_URL: "https://directus.universe.nexus",
NEXT_PUBLIC_DIRECTUS_URL: "https://directus.universe.nexus",
ADMIN_EMAIL: "FILL_ME_IN",
ADMIN_PASSWORD: "FILL_ME_IN",
LOGO_FOLDER_ID: "79d440d6-07f6-47ed-8448-57587f27e706",
Expand All @@ -47,7 +47,7 @@ const main = async () => {
);

const client = createDirectus<NoUndefinedField<ApiCollections>>(
CONFIG.DIRECTUS_URL,
CONFIG.NEXT_PUBLIC_DIRECTUS_URL,
)
.with(rest())
.with(authentication("json"));
Expand Down
5 changes: 2 additions & 3 deletions src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import { z } from "zod";

const server = z.object({
DIRECTUS_URL: z.string().min(1),
NODE_ENV: z.string().min(1),
});

const client = z.object({
// NEXT_PUBLIC_CLIENTVAR: z.string().min(1),
NEXT_PUBLIC_DIRECTUS_URL: z.string().min(1),
});

/**
Expand All @@ -16,7 +15,7 @@ const client = z.object({
* @type {Record<keyof z.infer<typeof server> | keyof z.infer<typeof client>, string | undefined>}
*/
const processEnv = {
DIRECTUS_URL: process.env.DIRECTUS_URL,
NEXT_PUBLIC_DIRECTUS_URL: process.env.NEXT_PUBLIC_DIRECTUS_URL,
NODE_ENV: process.env.NODE_ENV,
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
};
Expand Down
4 changes: 2 additions & 2 deletions src/server/api/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ type NoUndefinedField<T> = {
};
export const createTRPCContext = () => {
const directusSdk = createDirectus<NoUndefinedField<ApiCollections>>(
env.DIRECTUS_URL,
env.NEXT_PUBLIC_DIRECTUS_URL,
).with(rest());

const query = Chain(`${env.DIRECTUS_URL}/graphql`)("query");
const query = Chain(`${env.NEXT_PUBLIC_DIRECTUS_URL}/graphql`)("query");

return { directusSdk, query };
};
Expand Down
4 changes: 2 additions & 2 deletions src/utils/directus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const directusFileUrl = <
}

if (typeof fileId === "string") {
return `${env.DIRECTUS_URL}/assets/${fileId}` as R;
return `${env.NEXT_PUBLIC_DIRECTUS_URL}/assets/${fileId}` as R;
}

return `${env.DIRECTUS_URL}/assets/${fileId.id}` as R;
return `${env.NEXT_PUBLIC_DIRECTUS_URL}/assets/${fileId.id}` as R;
};

0 comments on commit e654d93

Please sign in to comment.