Add the option to set custom headers in the SW

This commit is contained in:
Hector Cuesta 2023-05-18 20:45:50 +01:00 committed by Bastien Wirtz
parent bbc88262ee
commit 95f1d94219
2 changed files with 13 additions and 0 deletions

View File

@ -31,6 +31,10 @@ connectivityCheck: true # whether you want to display a message when the apps ar
# Optional: Proxy / hosting option
proxy:
useCredentials: false # send cookies & authorization headers when fetching service specific data. Set to `true` if you use an authentication proxy. Can be overrided on service level.
headers: # send custom headers when fetching service specific data. Can also be set on a service level.
Test: "Example"
Test1: "Example1"
# Set the default layout and color scheme
defaults:

View File

@ -19,12 +19,21 @@ export default {
options.credentials = "include";
}
if (this.proxy?.headers) {
options.headers = this.proxy.headers;
}
// Each item can override the credential settings
if (this.item.useCredentials !== undefined) {
options.credentials =
this.item.useCredentials === true ? "include" : "omit";
}
// Each item can have their own headers
if (this.item.headers !== undefined) {
options.headers = this.item.headers;
}
options = Object.assign(options, init);
if (path.startsWith("/")) {