mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 03:49:11 +00:00
fix(utils): apiFetch should tolerate missing authentication
Signed-off-by: Katalina Okano <git@kat.cafe>
This commit is contained in:
parent
6d8f40e30e
commit
91c27f6b9a
1 changed files with 1 additions and 4 deletions
|
@ -28,15 +28,12 @@ export const apiFetch = async <T>(
|
||||||
context?: NextPageContext
|
context?: NextPageContext
|
||||||
): Promise<T | null> => {
|
): Promise<T | null> => {
|
||||||
const sessionKey = getSessionKey(context);
|
const sessionKey = getSessionKey(context);
|
||||||
if (!sessionKey) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const authorizedInit: RequestInit = {
|
const authorizedInit: RequestInit = {
|
||||||
...(init || {}),
|
...(init || {}),
|
||||||
headers: {
|
headers: {
|
||||||
...(init?.headers || {}),
|
...(init?.headers || {}),
|
||||||
authorization: `Bearer ${sessionKey}`,
|
authorization: sessionKey ? `Bearer ${sessionKey}` : '',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue