Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add warning about setting both useCdn and withCredentials to true #849

Merged
merged 4 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ export const initConfig = (

newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, '')
newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost

if (newConfig.useCdn === true && newConfig.withCredentials) {
warnings.printCdnAndWithCredentialsWarning()
}

// If `useCdn` is undefined, we treat it as `true`
newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials

Expand Down
5 changes: 5 additions & 0 deletions src/warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const createWarningPrinter = (message: string[]) =>
// eslint-disable-next-line no-console
once((...args: Any[]) => console.warn(message.join(' '), ...args))

export const printCdnAndWithCredentialsWarning = createWarningPrinter([
`Because you set \`withCredentials\` to true, we will override your \`useCdn\``,
`setting to be false since (cookie-based) credentials are never set on the CDN`,
])

export const printCdnWarning = createWarningPrinter([
`Since you haven't set a value for \`useCdn\`, we will deliver content using our`,
`global, edge-cached API-CDN. If you wish to have content delivered faster, set`,
Expand Down
Loading