@sanity/client 7.2.2 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.browser.cjs +3 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +12 -0
- package/dist/index.browser.d.ts +12 -0
- package/dist/index.browser.js +3 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +12 -0
- package/dist/stega.browser.d.ts +12 -0
- package/dist/stega.d.cts +12 -0
- package/dist/stega.d.ts +12 -0
- package/package.json +1 -1
- package/src/http/requestOptions.ts +4 -0
- package/src/types.ts +14 -0
- package/umd/sanityClient.js +3 -1
- package/umd/sanityClient.min.js +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,10 @@ export const client = createClient({
|
|
|
27
27
|
projectId: 'your-project-id',
|
|
28
28
|
dataset: 'your-dataset-name',
|
|
29
29
|
useCdn: true, // set to `false` to bypass the edge cache
|
|
30
|
+
// Set default headers to be included with all requests
|
|
31
|
+
headers: {
|
|
32
|
+
'X-Custom-Header': 'custom-value'
|
|
33
|
+
},
|
|
30
34
|
apiVersion: '2025-02-06', // use current date (YYYY-MM-DD) to target the latest API version. Note: this should always be hard coded. Setting API version based on a dynamic value (e.g. new Date()) may break your application at a random point in the future.
|
|
31
35
|
// token: process.env.SANITY_SECRET_TOKEN // Needed for certain operations like updating content, accessing drafts or using draft perspectives
|
|
32
36
|
})
|
package/dist/index.browser.cjs
CHANGED
|
@@ -738,7 +738,9 @@ class ObservableTransaction extends BaseTransaction {
|
|
|
738
738
|
}
|
|
739
739
|
const projectHeader = "X-Sanity-Project-ID";
|
|
740
740
|
function requestOptions(config, overrides = {}) {
|
|
741
|
-
const headers = {}
|
|
741
|
+
const headers = {};
|
|
742
|
+
config.headers && Object.assign(headers, config.headers);
|
|
743
|
+
const token = overrides.token || config.token;
|
|
742
744
|
token && (headers.Authorization = `Bearer ${token}`), !overrides.useGlobalApi && !config.useProjectHostname && config.projectId && (headers[projectHeader] = config.projectId);
|
|
743
745
|
const withCredentials = !!(typeof overrides.withCredentials > "u" ? config.withCredentials : overrides.withCredentials), timeout = typeof overrides.timeout > "u" ? config.timeout : overrides.timeout;
|
|
744
746
|
return Object.assign({}, overrides, {
|