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 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, }) }