From 1ec49f6fd4fa6f382da3484a51f252902889c04c Mon Sep 17 00:00:00 2001 From: Big Boss Date: Thu, 4 Jul 2024 13:37:46 -0500 Subject: [PATCH 1/3] add turnstile site key to docker (#541) * add turnstile site key to docker * fix QA notification URL * fix formatting --- .github/actions/deploy/action.yml | 6 +++--- apps/next/Dockerfile | 2 ++ docker-compose.yml | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml index a656cff09..f4be4e0b8 100644 --- a/.github/actions/deploy/action.yml +++ b/.github/actions/deploy/action.yml @@ -73,8 +73,8 @@ runs: sha=$(git rev-parse HEAD | cut -c1-7) summary=$(git log -1 --pretty=%B | head -n 1) if [ "${{ inputs.production }}" = "true" ]; then - data=$(printf "New production deployment is available. Summary: %s %s\n\nUnique URL: %s\n\nPublic Hostname: %s" "$summary" "$sha" "${{ steps.vercel-deploy.outputs.deployment-url }}" "https://${{ steps.public-hostname.outputs.public-hostname }}") + data=$(printf "New production deployment is available. Summary: %s %s\n\nUnique URL: <%s>\n\nPublic Hostname: <%s>" "$summary" "$sha" "${{ steps.vercel-deploy.outputs.deployment-url }}" <"https://${{ steps.public-hostname.outputs.public-hostname }}") else - data=$(printf "New staging deployment is available. Summary: %s %s\n\nUnique URL: %s\n\nPublic Hostname: %s" "$summary" "$sha" "${{ steps.vercel-deploy.outputs.deployment-url }}" "https://${{ steps.public-hostname.outputs.public-hostname }}") + data=$(printf "New staging deployment is available. Summary: %s %s\n\nUnique URL: <%s>\n\nPublic Hostname: <%s>" "$summary" "$sha" "${{ steps.vercel-deploy.outputs.deployment-url }}" <"https://${{ steps.public-hostname.outputs.public-hostname }}") fi - curl -X POST -d "$data" "${{ inputs.qa-notification-url }}" + curl -X POST -d "payload={\"text\":\"$data\"}" "${{ inputs.qa-notification-url }}" diff --git a/apps/next/Dockerfile b/apps/next/Dockerfile index 02388cedf..f86850e86 100644 --- a/apps/next/Dockerfile +++ b/apps/next/Dockerfile @@ -59,6 +59,7 @@ ARG NEXT_PUBLIC_BUNDLER_RPC_URL ARG NEXT_PUBLIC_MAINNET_CHAIN_ID ARG NEXT_PUBLIC_BASE_CHAIN_ID ARG NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID +ARG NEXT_PUBLIC_TURNSTILE_SITE_KEY ENV CI=${CI} ENV DEBUG=${DEBUG} ENV NEXT_PUBLIC_SUPABASE_PROJECT_ID=${NEXT_PUBLIC_SUPABASE_PROJECT_ID} @@ -72,6 +73,7 @@ ENV NEXT_PUBLIC_BUNDLER_RPC_URL=${NEXT_PUBLIC_BUNDLER_RPC_URL} ENV NEXT_PUBLIC_MAINNET_CHAIN_ID=${NEXT_PUBLIC_MAINNET_CHAIN_ID} ENV NEXT_PUBLIC_BASE_CHAIN_ID=${NEXT_PUBLIC_BASE_CHAIN_ID} ENV NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=${NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID} +ENV NEXT_PUBLIC_TURNSTILE_SITE_KEY=${NEXT_PUBLIC_TURNSTILE_SITE_KEY} ENV TAMAGUI_TARGET=web RUN --mount=type=cache,target=/tmp/yarn-cache \ --mount=type=cache,target=/tmp/turbo-cache \ diff --git a/docker-compose.yml b/docker-compose.yml index d39776233..ad4bbc2fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,6 +21,7 @@ services: - NEXT_PUBLIC_MAINNET_CHAIN_ID=${NEXT_PUBLIC_MAINNET_CHAIN_ID} - NEXT_PUBLIC_BASE_CHAIN_ID=${NEXT_PUBLIC_BASE_CHAIN_ID} - NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=${NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID} + - NEXT_PUBLIC_TURNSTILE_SITE_KEY=${NEXT_PUBLIC_TURNSTILE_SITE_KEY} secrets: - SUPABASE_DB_URL - SUPABASE_SERVICE_ROLE From 8b3fa7a49a45dac54e0bf7bbaa1ad14170ade0c4 Mon Sep 17 00:00:00 2001 From: Big Boss Date: Thu, 4 Jul 2024 13:55:50 -0500 Subject: [PATCH 2/3] bb/fix ci tilt (#542) * fix CI mode in tilt * fix deploy action --- .github/actions/deploy/action.yml | 4 ++-- Tiltfile | 2 +- tilt/common.tiltfile | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml index f4be4e0b8..147b35eb5 100644 --- a/.github/actions/deploy/action.yml +++ b/.github/actions/deploy/action.yml @@ -73,8 +73,8 @@ runs: sha=$(git rev-parse HEAD | cut -c1-7) summary=$(git log -1 --pretty=%B | head -n 1) if [ "${{ inputs.production }}" = "true" ]; then - data=$(printf "New production deployment is available. Summary: %s %s\n\nUnique URL: <%s>\n\nPublic Hostname: <%s>" "$summary" "$sha" "${{ steps.vercel-deploy.outputs.deployment-url }}" <"https://${{ steps.public-hostname.outputs.public-hostname }}") + data=$(printf "New production deployment is available. Summary: %s %s\n\nUnique URL: <%s>\n\nPublic Hostname: <%s>" "$summary" "$sha" "${{ steps.vercel-deploy.outputs.deployment-url }}" "https://${{ steps.public-hostname.outputs.public-hostname }}") else - data=$(printf "New staging deployment is available. Summary: %s %s\n\nUnique URL: <%s>\n\nPublic Hostname: <%s>" "$summary" "$sha" "${{ steps.vercel-deploy.outputs.deployment-url }}" <"https://${{ steps.public-hostname.outputs.public-hostname }}") + data=$(printf "New staging deployment is available. Summary: %s %s\n\nUnique URL: <%s>\n\nPublic Hostname: <%s>" "$summary" "$sha" "${{ steps.vercel-deploy.outputs.deployment-url }}" "https://${{ steps.public-hostname.outputs.public-hostname }}") fi curl -X POST -d "payload={\"text\":\"$data\"}" "${{ inputs.qa-notification-url }}" diff --git a/Tiltfile b/Tiltfile index 83ce4917c..ed220e606 100644 --- a/Tiltfile +++ b/Tiltfile @@ -258,7 +258,7 @@ local_resource( "playwright:test", "yarn playwright test", allow_parallel = True, - auto_init = CI == True, + auto_init = CI, labels = labels, resource_deps = [ "next:web", diff --git a/tilt/common.tiltfile b/tilt/common.tiltfile index 826911737..80fc823d6 100644 --- a/tilt/common.tiltfile +++ b/tilt/common.tiltfile @@ -7,10 +7,10 @@ contract_files = files_matching( DEBUG = os.getenv("DEBUG", "").find("tilt") != -1 -CI = os.getenv( +CI = bool(os.getenv( "CI", config.tilt_subcommand == "ci", -) +)) config.define_string_list( "args", From 37d2716f5227ed2f75f9fbc9483a82d02e89a694 Mon Sep 17 00:00:00 2001 From: Big Boss Date: Thu, 4 Jul 2024 14:12:37 -0500 Subject: [PATCH 3/3] log ip address during next requests (#543) --- apps/next/utils/logRequest.ts | 11 ++++++----- packages/api/src/trpc.ts | 13 +++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/next/utils/logRequest.ts b/apps/next/utils/logRequest.ts index 812942047..08b5a91ef 100644 --- a/apps/next/utils/logRequest.ts +++ b/apps/next/utils/logRequest.ts @@ -1,9 +1,10 @@ import type { GetServerSidePropsContext } from 'next' export function logRequest(ctx: GetServerSidePropsContext) { - console.log( - `${ctx.req.url} - ${ctx.req.headers['user-agent']}${ - ctx.req.headers['x-forwarded-for'] ? ` - ${ctx.req.headers['x-forwarded-for']}` : '' - }` - ) + const ip = + (ctx.req.headers['cf-connecting-ip'] || + ctx.req.headers['x-forwarded-for'] || + ctx.req.socket.remoteAddress) ?? + '' + console.log(`${ctx.req.url} - ${ctx.req.headers['user-agent']} - ${ip}`) } diff --git a/packages/api/src/trpc.ts b/packages/api/src/trpc.ts index e5b9620d6..a6ac58e28 100644 --- a/packages/api/src/trpc.ts +++ b/packages/api/src/trpc.ts @@ -5,17 +5,18 @@ import type { CreateNextContextOptions } from '@trpc/server/adapters/next' import superJson from 'superjson' export const createTRPCContext = async (opts: CreateNextContextOptions) => { - console.log( - `${opts.req.url} - ${opts.req.headers['user-agent']}${ - opts.req.headers['x-forwarded-for'] ? ` - ${opts.req.headers['x-forwarded-for']}` : '' - }` - ) + const ip = + (opts.req.headers['cf-connecting-ip'] || + opts.req.headers['x-forwarded-for'] || + opts.req.socket.remoteAddress) ?? + '' + console.log(`${opts.req.url} - ${opts.req.headers['user-agent']} - ${ip}`) // if there's auth cookie it'll be authenticated by this helper const supabase = createPagesServerClient(opts) - // native sends these instead of cookie auth if (opts.req.headers.authorization && opts.req.headers['refresh-token']) { + // native sends these instead of cookie auth const accessToken = opts.req.headers.authorization.split('Bearer ').pop() const refreshToken = opts.req.headers['refresh-token'] if (accessToken && typeof refreshToken === 'string') {