From 6ba657e6d089fee2a0b6c7c2ba74bc73a954c93b Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Wed, 4 Mar 2026 00:10:53 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20chore:=20fix=20to=20improve=20ga?= =?UTF-8?q?teway=20(#12647)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit improve gateway --- .github/workflows/deploy-device-gateway.yml | 40 --------------------- apps/device-gateway/src/index.ts | 13 +------ 2 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 .github/workflows/deploy-device-gateway.yml diff --git a/.github/workflows/deploy-device-gateway.yml b/.github/workflows/deploy-device-gateway.yml deleted file mode 100644 index 61f074f513..0000000000 --- a/.github/workflows/deploy-device-gateway.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Deploy Device Gateway - -permissions: - contents: read - -on: - push: - branches: [canary] - paths: - - 'apps/device-gateway/**' - workflow_dispatch: {} - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - deploy: - name: Deploy to Cloudflare - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - - uses: actions/setup-node@v6 - with: - node-version: 22 - - - uses: oven-sh/setup-bun@v2 - - - run: cd apps/device-gateway && bun i - - - name: Type check - run: cd apps/device-gateway && npx tsc --noEmit - - - name: Deploy - run: cd apps/device-gateway && npx wrangler deploy --route "$DEVICE_GATEWAY_DOMAIN" - env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - DEVICE_GATEWAY_DOMAIN: ${{ secrets.DEVICE_GATEWAY_DOMAIN }} diff --git a/apps/device-gateway/src/index.ts b/apps/device-gateway/src/index.ts index 91f2a89b89..355b1edd13 100644 --- a/apps/device-gateway/src/index.ts +++ b/apps/device-gateway/src/index.ts @@ -18,19 +18,8 @@ export default { const token = url.searchParams.get('token'); if (!token) return new Response('Missing token', { status: 401 }); - let userId: string; - try { - if (token === env.SERVICE_TOKEN) { - // Service token auth (for CLI debugging) - const uid = url.searchParams.get('userId'); - if (!uid) return new Response('Missing userId for service token auth', { status: 400 }); - userId = uid; - } else { - // JWT auth (normal desktop flow) - const result = await verifyDesktopToken(env, token); - userId = result.userId; - } + const { userId } = await verifyDesktopToken(env, token); const id = env.DEVICE_GATEWAY.idFromName(`user:${userId}`); const stub = env.DEVICE_GATEWAY.get(id);