Skip to content

Commit

Permalink
Add the option to set custom headers in the SW
Browse files Browse the repository at this point in the history
  • Loading branch information
h3ku authored and bastienwirtz committed Oct 27, 2024
1 parent bbc8826 commit 95f1d94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions src/mixins/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("/")) {
Expand Down

0 comments on commit 95f1d94

Please sign in to comment.