diff options
| author | Lukas Senionis <warliukz@gmail.com> | 2024-08-03 20:24:25 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-03 13:24:25 -0400 |
| commit | 3e50ce65a721ee6a8f930613dd196f92a9126c1d (patch) | |
| tree | b68ae0d6042eb50164436aa6f78ae74dec99950b /frontend/src/plugin-loader.tsx | |
| parent | adf5a763924f99429d9b7829fce5ae15f3977a4b (diff) | |
| download | decky-loader-3e50ce65a721ee6a8f930613dd196f92a9126c1d.tar.gz decky-loader-3e50ce65a721ee6a8f930613dd196f92a9126c1d.zip | |
fix: fetchNoCors and http_request data handling (#664)
Diffstat (limited to 'frontend/src/plugin-loader.tsx')
| -rw-r--r-- | frontend/src/plugin-loader.tsx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx index 6b954d69..f7d362a7 100644 --- a/frontend/src/plugin-loader.tsx +++ b/frontend/src/plugin-loader.tsx @@ -528,18 +528,22 @@ class PluginLoader extends Logger { // Same syntax as fetch but only supports the url-based syntax and an object for headers since it's the most common usage pattern fetchNoCors(input: string, init?: DeckyRequestInit | undefined): Promise<Response> { - const headers: { [name: string]: string } = { - ...(init?.headers as { [name: string]: string }), - 'X-Decky-Auth': deckyAuthToken, - 'X-Decky-Fetch-URL': input, + const { headers: initHeaders = {}, ...restOfInit } = init || {}; + const getPrefixedHeaders = () => { + let prefixedInitHeaders: { [name: string]: any } = {}; + for (const [key, value] of Object.entries(initHeaders)) { + prefixedInitHeaders[`X-Decky-Header-${key}`] = value; + } + return prefixedInitHeaders; }; + const headers: { [name: string]: string } = getPrefixedHeaders(); if (init?.excludedHeaders) { headers['X-Decky-Fetch-Excluded-Headers'] = init.excludedHeaders.join(', '); } - return fetch('http://127.0.0.1:1337/fetch', { - ...init, + return fetch(this.getExternalResourceURL(input), { + ...restOfInit, credentials: 'include', headers, }); |
