Skip to content

Commit

Permalink
fix: add warning about setting both useCdn and withCredentials to true (
Browse files Browse the repository at this point in the history
#849)

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

* fix: Remove semicolon and update warning message

* chore: fix prettier warning

Signed-off-by: Cody Olsen <81981+stipsan@users.noreply.github.com>

* chore: fix prettier (again)

Signed-off-by: Cody Olsen <81981+stipsan@users.noreply.github.com>

---------

Signed-off-by: Cody Olsen <81981+stipsan@users.noreply.github.com>
Co-authored-by: Cody Olsen <81981+stipsan@users.noreply.github.com>
  • Loading branch information
amrfarid140 and stipsan authored Jun 18, 2024
1 parent c5d8fd1 commit ae01edb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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

0 comments on commit ae01edb

Please sign in to comment.