vite-plugin-vercel 9.0.7 → 10.0.0-beta.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 +31 -168
- package/dist/api.d.ts +55 -0
- package/dist/api.js +9 -0
- package/dist/chunk-CR7Q2T4Q.js +75 -0
- package/dist/chunk-OCCU6UM5.js +33 -0
- package/dist/chunk-UTQ72LMT.js +13 -0
- package/dist/chunk-YN5MUEL2.js +34 -0
- package/dist/index.d.ts +8 -691
- package/dist/index.js +698 -685
- package/dist/types-BjqDHPFV.d.ts +121 -0
- package/dist/universal-middleware-dev.d.ts +17 -0
- package/dist/universal-middleware-dev.js +24 -0
- package/dist/universal-middleware-prod.d.ts +12 -0
- package/dist/universal-middleware-prod.js +20 -0
- package/dist/utils.d.ts +23 -0
- package/dist/utils.js +81 -0
- package/index.d.ts +0 -8
- package/package.json +29 -32
- package/dist/index.cjs +0 -829
- package/dist/index.d.cts +0 -694
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# vite-plugin-vercel
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> [!WARNING]
|
|
4
|
+
> :construction: Work In Progress
|
|
5
|
+
>
|
|
6
|
+
> You are on the [Vite Environment API](https://vite.dev/guide/api-environment.html#environment-configuration) development branch. Check out [v9 branch](https://github.com/magne4000/vite-plugin-vercel/tree/v9) current stable version.
|
|
7
|
+
|
|
8
|
+
Vercel adapter for [Vite 6](https://vitejs.dev/).
|
|
4
9
|
|
|
5
10
|
Bundle your Vite application as supported by [Vercel Output API (v3)](https://vercel.com/docs/build-output-api/v3).
|
|
6
11
|
|
|
@@ -45,27 +50,32 @@ Install this package as a dev dependency and add it to your Vite config:
|
|
|
45
50
|
// vite.config.ts
|
|
46
51
|
import { defineConfig } from 'vite';
|
|
47
52
|
import vercel from 'vite-plugin-vercel';
|
|
53
|
+
import { getEntriesFromFs } from "vite-plugin-vercel/utils";
|
|
48
54
|
|
|
49
55
|
export default defineConfig({
|
|
50
|
-
plugins: [vercel(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
plugins: [vercel({
|
|
57
|
+
entries: [
|
|
58
|
+
...(await getEntriesFromFs("endpoints/api", {
|
|
59
|
+
// Auto mapping examples:
|
|
60
|
+
// endpoints/api/page.ts -> /api/page
|
|
61
|
+
// endpoints/api/name/[name].ts -> /api/name/*
|
|
62
|
+
destination: "api",
|
|
63
|
+
}))
|
|
64
|
+
]
|
|
65
|
+
})],
|
|
54
66
|
});
|
|
55
67
|
```
|
|
56
68
|
|
|
57
69
|
> [!NOTE]
|
|
58
|
-
>
|
|
59
|
-
>
|
|
60
|
-
> with no way to disable it, thus avoiding double compilation and unexpected behaviour.
|
|
70
|
+
> `@vercel/build` currently forces the building of files in the _/api_ folder, with no way to disable this behavior.
|
|
71
|
+
> It's recommended to place your files in a different folder.
|
|
61
72
|
|
|
62
73
|
### Configure endpoints
|
|
63
74
|
|
|
64
|
-
Endpoints
|
|
65
|
-
by exporting values from the endpoint file:
|
|
75
|
+
Endpoints added via `getEntriesFromFs` can be configured by exporting values from the endpoint file:
|
|
66
76
|
|
|
67
77
|
```ts
|
|
68
|
-
// file:
|
|
78
|
+
// file: endpoints/api/endpoint.ts
|
|
69
79
|
|
|
70
80
|
// Should run on edge runtime
|
|
71
81
|
export const edge = true;
|
|
@@ -90,170 +100,23 @@ export default async function handler() {
|
|
|
90
100
|
}
|
|
91
101
|
```
|
|
92
102
|
|
|
93
|
-
> [!NOTE]
|
|
94
|
-
> Please create an issue if you need other per-endpoints configurations
|
|
95
|
-
|
|
96
103
|
### Edge middleware
|
|
97
104
|
|
|
98
105
|
You can use [Edge middleware as describe in the official documentation](https://vercel.com/docs/functions/edge-middleware/middleware-api) (i.e. with a `middleware.ts` file at the root of your project).
|
|
99
106
|
|
|
100
|
-
##
|
|
107
|
+
## FAQ
|
|
101
108
|
|
|
102
|
-
|
|
109
|
+
### What does ISR do in dev mode?
|
|
110
|
+
Nothing. It's a production-only feature
|
|
103
111
|
|
|
104
|
-
|
|
112
|
+
### What does `edge: true` target do in dev mode?
|
|
113
|
+
Nothing (yet?). If you have a use-case where an actual Edge runtime would be necessary in dev, please open a discussion
|
|
105
114
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```ts
|
|
109
|
-
// /pages/product/+config.ts
|
|
110
|
-
|
|
111
|
-
import Page from './Page';
|
|
112
|
-
import type { Config } from 'vike/types';
|
|
113
|
-
|
|
114
|
-
export default {
|
|
115
|
-
// Customize ISR config for this page
|
|
116
|
-
isr: { expiration: 15 },
|
|
117
|
-
// Target Edge instead of Serverless
|
|
118
|
-
edge: true,
|
|
119
|
-
// append headers to all responses
|
|
120
|
-
headers: {
|
|
121
|
-
'X-Header': 'value'
|
|
122
|
-
}
|
|
123
|
-
} satisfies Config;
|
|
124
|
-
```
|
|
115
|
+
### I don't see Vercel specific headers in dev mode
|
|
116
|
+
This is not yet supported. Please open an issue if you need this (PR welcome).
|
|
125
117
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
```ts
|
|
129
|
-
// /renderer/+config.ts
|
|
130
|
-
|
|
131
|
-
import config from '@vite-plugin-vercel/vike/config';
|
|
132
|
-
import type { Config } from 'vike/types';
|
|
133
|
-
|
|
134
|
-
export default {
|
|
135
|
-
extends: config,
|
|
136
|
-
} satisfies Config;
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Advanced usage
|
|
140
|
-
|
|
141
|
-
```ts
|
|
142
|
-
// vite.config.ts
|
|
143
|
-
import { defineConfig } from 'vite';
|
|
144
|
-
import vercel from 'vite-plugin-vercel';
|
|
145
|
-
|
|
146
|
-
export default defineConfig({
|
|
147
|
-
plugins: [vercel()],
|
|
148
|
-
vercel: {
|
|
149
|
-
// All the followings optional
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* How long Functions should be allowed to run for every request, in seconds.
|
|
153
|
-
* If left empty, default value for your plan will be used.
|
|
154
|
-
*/
|
|
155
|
-
defaultMaxDuration: 30,
|
|
156
|
-
/**
|
|
157
|
-
* Enable streaming responses by default for all Serverless Functions
|
|
158
|
-
*/
|
|
159
|
-
defaultSupportsResponseStreaming: true,
|
|
160
|
-
/**
|
|
161
|
-
* Default expiration time (in seconds) for prerender functions.
|
|
162
|
-
* Defaults to 86400 seconds (24h).
|
|
163
|
-
*/
|
|
164
|
-
expiration: 86400,
|
|
165
|
-
/**
|
|
166
|
-
* Also known as Server Side Generation, or SSG.
|
|
167
|
-
* If present, this function is responsible to create static files in `.vercel/output/static`.
|
|
168
|
-
* Defaults to `false`, which disables prerendering.
|
|
169
|
-
*/
|
|
170
|
-
prerender(resolvedConfig) {
|
|
171
|
-
// Check `/packages/vike/vike.ts` `prerender` for an example
|
|
172
|
-
},
|
|
173
|
-
/**
|
|
174
|
-
* See https://vercel.com/docs/projects/project-configuration#rewrites
|
|
175
|
-
*/
|
|
176
|
-
rewrites: [{ source: '/about', destination: '/about-our-company.html' }],
|
|
177
|
-
/**
|
|
178
|
-
* @see {@link https://vercel.com/docs/projects/project-configuration#headers}
|
|
179
|
-
*/
|
|
180
|
-
headers: [
|
|
181
|
-
{
|
|
182
|
-
"source": "/service-worker.js",
|
|
183
|
-
"headers": [
|
|
184
|
-
{
|
|
185
|
-
"key": "Cache-Control",
|
|
186
|
-
"value": "public, max-age=0, must-revalidate"
|
|
187
|
-
}
|
|
188
|
-
]
|
|
189
|
-
}
|
|
190
|
-
],
|
|
191
|
-
/**
|
|
192
|
-
* See https://vercel.com/docs/projects/project-configuration#redirects
|
|
193
|
-
*/
|
|
194
|
-
redirects: [
|
|
195
|
-
{ source: '/me', destination: '/profile.html', permanent: false },
|
|
196
|
-
],
|
|
197
|
-
/**
|
|
198
|
-
* See https://vercel.com/docs/projects/project-configuration#cleanurls
|
|
199
|
-
*/
|
|
200
|
-
cleanUrls: true,
|
|
201
|
-
/**
|
|
202
|
-
* See https://vercel.com/docs/projects/project-configuration#trailingslash
|
|
203
|
-
*/
|
|
204
|
-
trailingSlash: true,
|
|
205
|
-
/**
|
|
206
|
-
* By default, all `api/*` and `_api/*` endpoints are compiled under `.vercel/output/functions/api/*.func`.
|
|
207
|
-
* If others serverless functions need to be compiled under `.vercel/output/functions`, they should be added here.
|
|
208
|
-
* For instance, a framework can leverage this to have a generic ssr endpoint
|
|
209
|
-
* without requiring the user to write any code.
|
|
210
|
-
*/
|
|
211
|
-
additionalEndpoints: [
|
|
212
|
-
{
|
|
213
|
-
// can also be an Object representing an esbuild StdinOptions
|
|
214
|
-
source: '/path/to/file.ts',
|
|
215
|
-
// URL path of the handler, will be generated to `.vercel/output/functions/api/file.func/index.js`
|
|
216
|
-
destination: '/api/file',
|
|
217
|
-
},
|
|
218
|
-
],
|
|
219
|
-
/**
|
|
220
|
-
* Advanced configuration to override .vercel/output/config.json
|
|
221
|
-
* See https://vercel.com/docs/build-output-api/v3/configuration#configuration
|
|
222
|
-
*/
|
|
223
|
-
config: {
|
|
224
|
-
// routes?: Route[];
|
|
225
|
-
// images?: ImagesConfig;
|
|
226
|
-
// wildcard?: WildcardConfig;
|
|
227
|
-
// overrides?: OverrideConfig;
|
|
228
|
-
// cache?: string[];
|
|
229
|
-
// crons?: CronsConfig;
|
|
230
|
-
},
|
|
231
|
-
/**
|
|
232
|
-
* ISR and SSG pages are mutually exclusive. If a page is found in both, ISR prevails.
|
|
233
|
-
* Keys are path relative to .vercel/output/functions directory, either without extension,
|
|
234
|
-
* or with `.prerender-config.json` extension.
|
|
235
|
-
* If you have multiple isr configurations pointing to the same underlying function, you can leverage the `symlink`
|
|
236
|
-
* property.
|
|
237
|
-
*
|
|
238
|
-
* Can be an object or a function returning an object (or a Promise of an object).
|
|
239
|
-
*
|
|
240
|
-
* Check `/packages/vike/vike.ts` `vitePluginVercelVpsIsrPlugin` for advanced usage.
|
|
241
|
-
*/
|
|
242
|
-
isr: {
|
|
243
|
-
// `symlink: 'ssr_'` means that a function is available under `.vercel/output/functions/ssr_.func`
|
|
244
|
-
'/pages/a': { expiration: 15, symlink: 'ssr_', route: '^/a/.*$' },
|
|
245
|
-
'/pages/b/c': { expiration: 15, symlink: 'ssr_', route: '^/b/c/.*$' },
|
|
246
|
-
'/pages/d': { expiration: 15, symlink: 'ssr_', route: '^/d$' },
|
|
247
|
-
'/pages/e': { expiration: 25 },
|
|
248
|
-
},
|
|
249
|
-
/**
|
|
250
|
-
* Defaults to `.vercel/output`. Mostly useful for testing purpose
|
|
251
|
-
*/
|
|
252
|
-
outDir: '.vercel/output',
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
```
|
|
118
|
+
Related documentation: https://vercel.com/docs/edge-network/headers/request-headers
|
|
256
119
|
|
|
257
|
-
##
|
|
120
|
+
## Migration from v9
|
|
258
121
|
|
|
259
|
-
|
|
122
|
+
TODO
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="@photonjs/core" />
|
|
2
|
+
|
|
3
|
+
import * as _vercel_routing_utils from '@vercel/routing-utils';
|
|
4
|
+
import { V as ViteVercelConfig, a as ViteVercelRewrite, b as ViteVercelRedirect } from './types-BjqDHPFV.js';
|
|
5
|
+
import { PluginContext } from 'rollup';
|
|
6
|
+
import { ViteDevServer } from 'vite';
|
|
7
|
+
import { Photon } from '@photonjs/core';
|
|
8
|
+
import { VercelOutputConfig } from '@vite-plugin-vercel/schemas';
|
|
9
|
+
|
|
10
|
+
declare function createAPI(outfiles: ViteVercelOutFile[], pluginConfig: ViteVercelConfig): {
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
getOutFiles(): ViteVercelOutFile[];
|
|
15
|
+
readonly config: Partial<Omit<VercelOutputConfig, "version">>;
|
|
16
|
+
defaultMaxDuration: number | undefined;
|
|
17
|
+
expiration: number | undefined;
|
|
18
|
+
readonly rewrites: ViteVercelRewrite[];
|
|
19
|
+
readonly headers: _vercel_routing_utils.Header[];
|
|
20
|
+
readonly redirects: ViteVercelRedirect[];
|
|
21
|
+
cleanUrls: boolean | undefined;
|
|
22
|
+
trailingSlash: boolean | undefined;
|
|
23
|
+
defaultSupportsResponseStreaming: boolean | undefined;
|
|
24
|
+
};
|
|
25
|
+
declare function getVercelAPI(pluginContextOrServer: PluginContext | ViteDevServer): {
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
getOutFiles(): ViteVercelOutFile[];
|
|
30
|
+
readonly config: Partial<Omit<VercelOutputConfig, "version">>;
|
|
31
|
+
defaultMaxDuration: number | undefined;
|
|
32
|
+
expiration: number | undefined;
|
|
33
|
+
readonly rewrites: ViteVercelRewrite[];
|
|
34
|
+
readonly headers: _vercel_routing_utils.Header[];
|
|
35
|
+
readonly redirects: ViteVercelRedirect[];
|
|
36
|
+
cleanUrls: boolean | undefined;
|
|
37
|
+
trailingSlash: boolean | undefined;
|
|
38
|
+
defaultSupportsResponseStreaming: boolean | undefined;
|
|
39
|
+
};
|
|
40
|
+
type ViteVercelApi = ReturnType<typeof createAPI>;
|
|
41
|
+
type ViteVercelOutFile = ViteVercelOutFileChunk | ViteVercelOutFileAsset;
|
|
42
|
+
interface ViteVercelOutFileCommon {
|
|
43
|
+
filepath: string;
|
|
44
|
+
root: string;
|
|
45
|
+
outdir: string;
|
|
46
|
+
}
|
|
47
|
+
interface ViteVercelOutFileChunk extends ViteVercelOutFileCommon {
|
|
48
|
+
type: "chunk";
|
|
49
|
+
relatedEntry: Photon.Entry;
|
|
50
|
+
}
|
|
51
|
+
interface ViteVercelOutFileAsset extends ViteVercelOutFileCommon {
|
|
52
|
+
type: "asset";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { type ViteVercelApi, type ViteVercelOutFile, type ViteVercelOutFileAsset, type ViteVercelOutFileChunk, createAPI, getVercelAPI };
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assert
|
|
3
|
+
} from "./chunk-UTQ72LMT.js";
|
|
4
|
+
|
|
5
|
+
// src/api.ts
|
|
6
|
+
function createAPI(outfiles, pluginConfig) {
|
|
7
|
+
return {
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
getOutFiles() {
|
|
12
|
+
return outfiles;
|
|
13
|
+
},
|
|
14
|
+
get config() {
|
|
15
|
+
pluginConfig.config ??= {};
|
|
16
|
+
return pluginConfig.config;
|
|
17
|
+
},
|
|
18
|
+
get defaultMaxDuration() {
|
|
19
|
+
return pluginConfig.defaultMaxDuration;
|
|
20
|
+
},
|
|
21
|
+
set defaultMaxDuration(value) {
|
|
22
|
+
pluginConfig.defaultMaxDuration = value;
|
|
23
|
+
},
|
|
24
|
+
get expiration() {
|
|
25
|
+
return pluginConfig.expiration;
|
|
26
|
+
},
|
|
27
|
+
set expiration(value) {
|
|
28
|
+
pluginConfig.expiration = value;
|
|
29
|
+
},
|
|
30
|
+
get rewrites() {
|
|
31
|
+
pluginConfig.rewrites ??= [];
|
|
32
|
+
return pluginConfig.rewrites;
|
|
33
|
+
},
|
|
34
|
+
get headers() {
|
|
35
|
+
pluginConfig.headers ??= [];
|
|
36
|
+
return pluginConfig.headers;
|
|
37
|
+
},
|
|
38
|
+
get redirects() {
|
|
39
|
+
pluginConfig.redirects ??= [];
|
|
40
|
+
return pluginConfig.redirects;
|
|
41
|
+
},
|
|
42
|
+
get cleanUrls() {
|
|
43
|
+
return pluginConfig.cleanUrls;
|
|
44
|
+
},
|
|
45
|
+
set cleanUrls(value) {
|
|
46
|
+
pluginConfig.cleanUrls = value;
|
|
47
|
+
},
|
|
48
|
+
get trailingSlash() {
|
|
49
|
+
return pluginConfig.trailingSlash;
|
|
50
|
+
},
|
|
51
|
+
set trailingSlash(value) {
|
|
52
|
+
pluginConfig.trailingSlash = value;
|
|
53
|
+
},
|
|
54
|
+
get defaultSupportsResponseStreaming() {
|
|
55
|
+
return pluginConfig.defaultSupportsResponseStreaming;
|
|
56
|
+
},
|
|
57
|
+
set defaultSupportsResponseStreaming(value) {
|
|
58
|
+
pluginConfig.defaultSupportsResponseStreaming = value;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function getVercelAPI(pluginContextOrServer) {
|
|
63
|
+
const config = "environment" in pluginContextOrServer ? pluginContextOrServer.environment.config : pluginContextOrServer.config;
|
|
64
|
+
const vpv = config.plugins.find(
|
|
65
|
+
(p) => p.name === "vite-plugin-vercel:api"
|
|
66
|
+
);
|
|
67
|
+
assert(vpv, "Could not find vite-plugin-vercel:api plugin");
|
|
68
|
+
assert(vpv.api, "Missing `api`. Make sure vite-plugin-vercel is up-to-date");
|
|
69
|
+
return vpv.api("environment" in pluginContextOrServer ? pluginContextOrServer : void 0);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
createAPI,
|
|
74
|
+
getVercelAPI
|
|
75
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assert
|
|
3
|
+
} from "./chunk-UTQ72LMT.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/destination.ts
|
|
6
|
+
import path from "path";
|
|
7
|
+
function photonEntryDestinationDefault(entry) {
|
|
8
|
+
return entry.vercel?.destination ?? entry.name.replace(/[^a-zA-Z0-9\-_[\]/]/g, "-");
|
|
9
|
+
}
|
|
10
|
+
function photonEntryDestination(entry, postfix) {
|
|
11
|
+
return `${path.posix.join("functions/", photonEntryDestinationDefault(entry))}${postfix}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// src/utils/route.ts
|
|
15
|
+
import { toPathToRegexpV6 } from "convert-route/path-to-regexp-v6";
|
|
16
|
+
import { fromNextFs } from "convert-route/next-fs";
|
|
17
|
+
import path2 from "path";
|
|
18
|
+
import { toRou3 } from "convert-route";
|
|
19
|
+
function entryToPathtoregex(entry) {
|
|
20
|
+
assert(typeof entry.vercel?.route !== "string", "Do not pass entry with route string to entryToPathtoregex");
|
|
21
|
+
return toPathToRegexpV6(fromNextFs(path2.posix.resolve("/", photonEntryDestinationDefault(entry))));
|
|
22
|
+
}
|
|
23
|
+
function entryToRou3(entry) {
|
|
24
|
+
assert(typeof entry.vercel?.route !== "string", "Do not pass entry with route string to entryToPathtoregex");
|
|
25
|
+
return toRou3(fromNextFs(path2.posix.resolve("/", photonEntryDestinationDefault(entry))));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
photonEntryDestinationDefault,
|
|
30
|
+
photonEntryDestination,
|
|
31
|
+
entryToPathtoregex,
|
|
32
|
+
entryToRou3
|
|
33
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/assert.ts
|
|
2
|
+
import { newError } from "@brillout/libassert";
|
|
3
|
+
function assert(condition, errorMessage) {
|
|
4
|
+
if (condition) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const err = newError(`["vite-plugin-vercel"] ${errorMessage}`, 2);
|
|
8
|
+
throw err;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
assert
|
|
13
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/utils/original-request.ts
|
|
2
|
+
function getOriginalRequest(request) {
|
|
3
|
+
const xNowRouteMatchesHeader = request.headers.get("x-now-route-matches");
|
|
4
|
+
const originalUrl = new URL(request.url);
|
|
5
|
+
const originalPath = originalUrl.searchParams.get("__original_path");
|
|
6
|
+
let newUrl = null;
|
|
7
|
+
let newRequest = request;
|
|
8
|
+
if (originalPath) {
|
|
9
|
+
newUrl = new URL(originalPath, request.url).toString();
|
|
10
|
+
} else if (typeof xNowRouteMatchesHeader === "string") {
|
|
11
|
+
const originalPathBis = new URLSearchParams(xNowRouteMatchesHeader).get("1");
|
|
12
|
+
if (originalPathBis) {
|
|
13
|
+
newUrl = new URL(originalPathBis, request.url).toString();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (newUrl) {
|
|
17
|
+
newRequest = new Request(newUrl, {
|
|
18
|
+
method: request.method,
|
|
19
|
+
headers: request.headers,
|
|
20
|
+
body: request.body,
|
|
21
|
+
mode: request.mode,
|
|
22
|
+
credentials: request.credentials,
|
|
23
|
+
cache: request.cache,
|
|
24
|
+
redirect: request.redirect,
|
|
25
|
+
referrer: request.referrer,
|
|
26
|
+
integrity: request.integrity
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return newRequest;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
getOriginalRequest
|
|
34
|
+
};
|