Skip to content

Commit

Permalink
fix: only add credentials on client-side
Browse files Browse the repository at this point in the history
resolves #660
  • Loading branch information
danielroe committed Mar 7, 2024
1 parent feea9d0 commit ec44f94
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/runtime/minimal-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ export function createClient (config: ClientConfig) {
const useCdn = perspective !== 'previewDrafts' && config.useCdn

const fetchOptions: RequestInit = {
credentials: withCredentials ? 'include' : 'omit',
headers: {
...(token ? { Authorization: `Bearer ${token}` } : {}),
Accept: 'application/json',
...(process.server ? { 'accept-encoding': 'gzip, deflate' } : {}),
},
}

if (import.meta.client) {
fetchOptions.credentials = withCredentials ? 'include' : 'omit'
}

return {
clone: () =>
createClient({
Expand Down

0 comments on commit ec44f94

Please sign in to comment.