From 8483d313c57cf96b53d722be9b3870c735efaf74 Mon Sep 17 00:00:00 2001 From: kunish Date: Wed, 13 Sep 2023 15:26:40 +0800 Subject: [PATCH 1/2] refactor: set api authorization headers --- src/signals/request.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/signals/request.ts b/src/signals/request.ts index 9c2daba..fa04bd5 100644 --- a/src/signals/request.ts +++ b/src/signals/request.ts @@ -26,9 +26,19 @@ export const [endpointList, setEndpointList] = makePersisted( export const useRequest = () => { const e = endpoint() + if (!e) { + return ky.create({}) + } + + const headers = new Headers() + + if (e.secret) { + headers.set('Authorization', `Bearer ${e.secret}`) + } + return ky.create({ - prefixUrl: e?.url, - headers: { Authorization: e?.secret ? `Bearer ${e.secret}` : '' }, + prefixUrl: e.url, + headers, }) } From 716fc2e93c615db423535706adae0f877d5718ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:03:49 +0800 Subject: [PATCH 2/2] chore(deps): bump uuid from 9.0.0 to 9.0.1 (#210) Bumps [uuid](https://github.com/uuidjs/uuid) from 9.0.0 to 9.0.1. - [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md) - [Commits](https://github.com/uuidjs/uuid/compare/v9.0.0...v9.0.1) --- updated-dependencies: - dependency-name: uuid dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 547ad48..5d76d8b 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "tailwindcss": "^3.3.3", "tailwindcss-safe-area": "^0.4.0", "typescript": "^5.2.2", - "uuid": "^9.0.0", + "uuid": "^9.0.1", "vite": "^4.4.9", "vite-plugin-pwa": "^0.16.5", "vite-plugin-solid": "^2.7.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index acf4d2b..d93c65a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -156,8 +156,8 @@ dependencies: specifier: ^5.2.2 version: 5.2.2 uuid: - specifier: ^9.0.0 - version: 9.0.0 + specifier: ^9.0.1 + version: 9.0.1 vite: specifier: ^4.4.9 version: 4.4.9(@types/node@20.6.0) @@ -5894,8 +5894,8 @@ packages: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} dev: false - /uuid@9.0.0: - resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==} + /uuid@9.0.1: + resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} hasBin: true dev: false