From a0107eeb276a6df734a0497484f09dde91c0a45e Mon Sep 17 00:00:00 2001 From: Lucid Date: Sat, 6 Dec 2025 20:32:09 -0500 Subject: [PATCH] added api token to urql and env example --- .env.example | 3 ++- src/lib/urql.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index d51116e..8acb71f 100644 --- a/.env.example +++ b/.env.example @@ -8,4 +8,5 @@ SERVER_HOST=localhost SERVER_PORT=3000 BOT_ADMINS=[1] GROUP_IDS=- -GRAPHQL_URL=http://localhost:3000/api/graphql \ No newline at end of file +GRAPHQL_URL=http://localhost:3000/api/graphql +API_TOKEN="token-here" \ No newline at end of file diff --git a/src/lib/urql.ts b/src/lib/urql.ts index 4a75210..dbe6632 100644 --- a/src/lib/urql.ts +++ b/src/lib/urql.ts @@ -2,9 +2,12 @@ import { Client, cacheExchange, fetchExchange } from "@urql/core"; const urql = new Client({ url: process.env.GRAPHQL_URL || "", - exchanges: [cacheExchange, fetchExchange] + exchanges: [cacheExchange, fetchExchange], + fetchOptions: { + headers: { + "x-api-key": process.env?.API_TOKEN || "" + } + } }); -console.log(`GRAPHQL_URL`, process.env.GRAPHQL_URL); - export default urql;