Skip to content

Commit

Permalink
Merge branch 'main' into rm-env-id
Browse files Browse the repository at this point in the history
  • Loading branch information
peintnermax authored Feb 24, 2025
2 parents b8571dc + 19abbfc commit 65712da
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*
!docker
/*
!/docker
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ jobs:
run: pnpm install

- name: Build for Docker
run: NEXT_PUBLIC_BASE_PATH=/new-login pnpm build:docker
run: NEXT_PUBLIC_BASE_PATH=/ui/v2/login pnpm build:docker

- name: Build and Push Image
id: build
uses: docker/build-push-action@v5
timeout-minutes: 10
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'

- name: Setup Cypress binary cache
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-binary-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-cypress-binary-
# The Cypress binary cache needs to be updated together with the pnpm dependencies cache.
# That's why we don't conditionally cache it using if: ${{ matrix.command == 'test:integration' }}

- name: Install Dependencies
run: pnpm install --frozen-lockfile
Expand Down
14 changes: 6 additions & 8 deletions apps/login/next-env-vars.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ declare namespace NodeJS {
*/
ZITADEL_API_URL: string;

/**
* Takes effect only if ZITADEL_API_URL is not empty.
* This is only relevant if Zitadels runtime has the ZITADEL_INSTANCEHOSTHEADERS config changed.
* The default is x-zitadel-instance-host.
* Most users don't need to set this variable.
*/
ZITADEL_INSTANCE_HOST_HEADER: string;

/**
* Self hosting: The service user token
*/
Expand All @@ -31,5 +23,11 @@ declare namespace NodeJS {
* Optional: wheter a user must have verified email
*/
EMAIL_VERIFICATION: string;

/**
* Optional: custom request headers to be added to every request
* Split by comma, key value pairs separated by colon
*/
CUSTOM_REQUEST_HEADERS: string;
}
}
35 changes: 16 additions & 19 deletions apps/login/src/lib/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,23 @@ export async function createServiceForHost<T extends ServiceClass>(
throw new Error("No token found");
}

const instanceHost = new URL(serviceUrl).host;
const transport = createServerTransport(token, {
baseUrl: process.env.ZITADEL_API_URL ?? serviceUrl,
interceptors:
(process.env.ZITADEL_API_URL &&
process.env.ZITADEL_API_URL != serviceUrl) ||
process.env.ZITADEL_INSTANCE_HOST_HEADER
? [
(next) => {
return (req) => {
req.header.set(
process.env.ZITADEL_INSTANCE_HOST_HEADER ??
"x-zitadel-instance-host",
instanceHost,
);
return next(req);
};
},
]
: undefined,
baseUrl: serviceUrl,
interceptors: !process.env.CUSTOM_REQUEST_HEADERS
? undefined
: [
(next) => {
return (req) => {
process.env.CUSTOM_REQUEST_HEADERS.split(",").forEach(
(header) => {
const kv = header.split(":");
req.header.set(kv[0], kv[1]);
},
);
return next(req);
};
},
],
});

return createClientFor<T>(service)(transport);
Expand Down
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": {
"generate": "turbo run generate",
"build": "turbo run build",
"build:docker": "rm -rf ./out ./docker && mkdir -p ./docker && turbo run build --filter=./packages/zitadel-client && turbo prune @zitadel/login --docker && cd ./docker && cp -r ../out/json/* . && pnpm install --frozen-lockfile && cp -r ../out/full/* . && turbo run build:standalone && cd ..",
"build:docker": "rm -rf ./out ./docker && turbo run build --filter=./packages/zitadel-client && turbo prune @zitadel/login --docker && mkdir -p ./docker && cd ./docker && cp -r ../out/json/* . && pnpm install --frozen-lockfile && cp -r ../out/full/* . && turbo run build:standalone && cd ..",
"build:packages": "turbo run build --filter=./packages/*",
"build:apps": "turbo run build --filter=./apps/*",
"test": "turbo run test",
Expand Down
2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"ZITADEL_API_URL",
"ZITADEL_SERVICE_USER_TOKEN",
"NEXT_PUBLIC_BASE_PATH",
"ZITADEL_INSTANCE_HOST_HEADER"
"CUSTOM_REQUEST_HEADERS"
],
"tasks": {
"generate": {
Expand Down

0 comments on commit 65712da

Please sign in to comment.