@vercel/functions 3.5.0 → 3.5.1
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/CHANGELOG.md +8 -0
- package/docs/README.md +7 -5
- package/docs/index/README.md +37 -0
- package/docs/index/functions/addCacheTag.md +19 -0
- package/docs/index/functions/attachDatabasePool.md +45 -0
- package/docs/index/functions/dangerouslyDeleteBySrcImage.md +23 -0
- package/docs/index/functions/dangerouslyDeleteByTag.md +23 -0
- package/docs/index/functions/geolocation.md +49 -0
- package/docs/index/functions/getCache.md +36 -0
- package/docs/index/functions/getEnv.md +291 -0
- package/docs/index/functions/invalidateBySrcImage.md +19 -0
- package/docs/index/functions/invalidateByTag.md +19 -0
- package/docs/index/functions/ipAddress.md +36 -0
- package/docs/index/functions/next.md +47 -0
- package/docs/index/functions/rewrite.md +66 -0
- package/docs/index/functions/waitUntil.md +38 -0
- package/docs/index/interfaces/DangerouslyDeleteOptions.md +18 -0
- package/docs/index/interfaces/Geo.md +90 -0
- package/docs/index/interfaces/PurgeApi.md +123 -0
- package/docs/index/interfaces/Request.md +19 -0
- package/docs/index/interfaces/RuntimeCache.md +133 -0
- package/docs/index/type-aliases/AddCacheTagApi.md +26 -0
- package/docs/index/variables/experimental_attachDatabasePool.md +49 -0
- package/docs/oidc/README.md +15 -0
- package/docs/oidc/functions/awsCredentialsProvider.md +24 -0
- package/docs/oidc/functions/getVercelOidcToken.md +58 -0
- package/docs/oidc/functions/getVercelOidcTokenSync.md +36 -0
- package/docs/oidc/interfaces/AwsCredentialsProviderInit.md +195 -0
- package/package.json +5 -5
- package/docs/interfaces/index.DangerouslyDeleteOptions.md +0 -22
- package/docs/interfaces/index.Geo.md +0 -115
- package/docs/interfaces/index.PurgeApi.md +0 -134
- package/docs/interfaces/index.Request.md +0 -23
- package/docs/interfaces/index.RuntimeCache.md +0 -131
- package/docs/interfaces/oidc.AwsCredentialsProviderInit.md +0 -221
- package/docs/modules/index.md +0 -536
- package/docs/modules/oidc.md +0 -133
package/CHANGELOG.md
CHANGED
package/docs/README.md
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[**@vercel/functions**](../README.md)
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# index
|
|
6
|
+
|
|
7
|
+
## Interfaces
|
|
8
|
+
|
|
9
|
+
- [DangerouslyDeleteOptions](interfaces/DangerouslyDeleteOptions.md)
|
|
10
|
+
- [Geo](interfaces/Geo.md)
|
|
11
|
+
- [PurgeApi](interfaces/PurgeApi.md)
|
|
12
|
+
- [Request](interfaces/Request.md)
|
|
13
|
+
- [RuntimeCache](interfaces/RuntimeCache.md)
|
|
14
|
+
|
|
15
|
+
## Type Aliases
|
|
16
|
+
|
|
17
|
+
- [AddCacheTagApi](type-aliases/AddCacheTagApi.md)
|
|
18
|
+
|
|
19
|
+
## Variables
|
|
20
|
+
|
|
21
|
+
- [~~experimental_attachDatabasePool~~](variables/experimental_attachDatabasePool.md)
|
|
22
|
+
|
|
23
|
+
## Functions
|
|
24
|
+
|
|
25
|
+
- [addCacheTag](functions/addCacheTag.md)
|
|
26
|
+
- [attachDatabasePool](functions/attachDatabasePool.md)
|
|
27
|
+
- [dangerouslyDeleteBySrcImage](functions/dangerouslyDeleteBySrcImage.md)
|
|
28
|
+
- [dangerouslyDeleteByTag](functions/dangerouslyDeleteByTag.md)
|
|
29
|
+
- [geolocation](functions/geolocation.md)
|
|
30
|
+
- [getCache](functions/getCache.md)
|
|
31
|
+
- [getEnv](functions/getEnv.md)
|
|
32
|
+
- [invalidateBySrcImage](functions/invalidateBySrcImage.md)
|
|
33
|
+
- [invalidateByTag](functions/invalidateByTag.md)
|
|
34
|
+
- [ipAddress](functions/ipAddress.md)
|
|
35
|
+
- [next](functions/next.md)
|
|
36
|
+
- [rewrite](functions/rewrite.md)
|
|
37
|
+
- [waitUntil](functions/waitUntil.md)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: addCacheTag()
|
|
6
|
+
|
|
7
|
+
> **addCacheTag**(`tag`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/addcachetag/index.ts:3](https://github.com/vercel/vercel/blob/main/packages/functions/src/addcachetag/index.ts#L3)
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
### tag
|
|
14
|
+
|
|
15
|
+
`string` \| `string`[]
|
|
16
|
+
|
|
17
|
+
## Returns
|
|
18
|
+
|
|
19
|
+
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: attachDatabasePool()
|
|
6
|
+
|
|
7
|
+
> **attachDatabasePool**(`dbPool`): `void`
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/db-connections/index.ts:225](https://github.com/vercel/vercel/blob/main/packages/functions/src/db-connections/index.ts#L225)
|
|
10
|
+
|
|
11
|
+
**`Experimental`**
|
|
12
|
+
|
|
13
|
+
Call this function right after creating a database pool with the database pool object
|
|
14
|
+
as argument.
|
|
15
|
+
This ensures that the current function instance stays alive long enough for
|
|
16
|
+
idle database connections to be removed from the pool.
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
### dbPool
|
|
21
|
+
|
|
22
|
+
`DbPool`
|
|
23
|
+
|
|
24
|
+
The database pool object. The supported pool types are:
|
|
25
|
+
- PostgreSQL (pg)
|
|
26
|
+
- MySQL2
|
|
27
|
+
- MariaDB
|
|
28
|
+
- MongoDB
|
|
29
|
+
- Redis (ioredis)
|
|
30
|
+
- Cassandra (cassandra-driver)
|
|
31
|
+
- OTHER: This method uses duck-typing to detect the pool type. Respectively you can
|
|
32
|
+
pass in any object with a compatible interface.
|
|
33
|
+
|
|
34
|
+
## Returns
|
|
35
|
+
|
|
36
|
+
`void`
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const pgPool = new Pool({
|
|
42
|
+
connectionString: process.env.DATABASE_URL,
|
|
43
|
+
});
|
|
44
|
+
attachDatabasePool(pgPool);
|
|
45
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: dangerouslyDeleteBySrcImage()
|
|
6
|
+
|
|
7
|
+
> **dangerouslyDeleteBySrcImage**(`src`, `options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/purge/index.ts:28](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L28)
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
### src
|
|
14
|
+
|
|
15
|
+
`string` \| `string`[]
|
|
16
|
+
|
|
17
|
+
### options?
|
|
18
|
+
|
|
19
|
+
[`DangerouslyDeleteOptions`](../interfaces/DangerouslyDeleteOptions.md)
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: dangerouslyDeleteByTag()
|
|
6
|
+
|
|
7
|
+
> **dangerouslyDeleteByTag**(`tag`, `options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/purge/index.ts:12](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L12)
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
### tag
|
|
14
|
+
|
|
15
|
+
`string` \| `string`[]
|
|
16
|
+
|
|
17
|
+
### options?
|
|
18
|
+
|
|
19
|
+
[`DangerouslyDeleteOptions`](../interfaces/DangerouslyDeleteOptions.md)
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: geolocation()
|
|
6
|
+
|
|
7
|
+
> **geolocation**(`request`): [`Geo`](../interfaces/Geo.md)
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/headers.ts:180](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L180)
|
|
10
|
+
|
|
11
|
+
Returns the location information for the incoming request.
|
|
12
|
+
|
|
13
|
+
## Parameters
|
|
14
|
+
|
|
15
|
+
### request
|
|
16
|
+
|
|
17
|
+
[`Request`](../interfaces/Request.md)
|
|
18
|
+
|
|
19
|
+
The incoming request object which provides the geolocation data
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
[`Geo`](../interfaces/Geo.md)
|
|
24
|
+
|
|
25
|
+
The location information of the request, in this way:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"city": "New York",
|
|
30
|
+
"country": "US",
|
|
31
|
+
"flag": "🇺🇸",
|
|
32
|
+
"countryRegion": "NY",
|
|
33
|
+
"region": "iad1",
|
|
34
|
+
"latitude": "40.7128",
|
|
35
|
+
"longitude": "-74.0060"
|
|
36
|
+
"postalCode": "10001"
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import { geolocation } from '@vercel/functions';
|
|
44
|
+
|
|
45
|
+
export function GET(request) {
|
|
46
|
+
const details = geolocation(request);
|
|
47
|
+
return Response.json(details);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: getCache()
|
|
6
|
+
|
|
7
|
+
> **getCache**(`cacheOptions?`): [`RuntimeCache`](../interfaces/RuntimeCache.md)
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/cache/index.ts:33](https://github.com/vercel/vercel/blob/main/packages/functions/src/cache/index.ts#L33)
|
|
10
|
+
|
|
11
|
+
Retrieves the Vercel Runtime Cache.
|
|
12
|
+
|
|
13
|
+
Keys are hashed to ensure they are unique and consistent. The hashing function can be overridden by providing a custom
|
|
14
|
+
`keyHashFunction` in the `cacheOptions` parameter.
|
|
15
|
+
|
|
16
|
+
To specify a namespace for the cache keys, you can pass a `namespace` option in the `cacheOptions` parameter. If
|
|
17
|
+
a namespace is provided, the cache keys will be prefixed with the namespace followed by a separator (default is `$`). The
|
|
18
|
+
namespaceSeparator can also be customized using the `namespaceSeparator` option.
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
### cacheOptions?
|
|
23
|
+
|
|
24
|
+
`CacheOptions`
|
|
25
|
+
|
|
26
|
+
Optional configuration for the cache.
|
|
27
|
+
|
|
28
|
+
## Returns
|
|
29
|
+
|
|
30
|
+
[`RuntimeCache`](../interfaces/RuntimeCache.md)
|
|
31
|
+
|
|
32
|
+
An instance of the Vercel Runtime Cache.
|
|
33
|
+
|
|
34
|
+
## Throws
|
|
35
|
+
|
|
36
|
+
If no cache is available in the context and `InMemoryCache` cannot be created.
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: getEnv()
|
|
6
|
+
|
|
7
|
+
> **getEnv**(`env?`): `object`
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/get-env.ts:6](https://github.com/vercel/vercel/blob/main/packages/functions/src/get-env.ts#L6)
|
|
10
|
+
|
|
11
|
+
Get System Environment Variables exposed by Vercel.
|
|
12
|
+
|
|
13
|
+
## Parameters
|
|
14
|
+
|
|
15
|
+
### env?
|
|
16
|
+
|
|
17
|
+
## Returns
|
|
18
|
+
|
|
19
|
+
### CI
|
|
20
|
+
|
|
21
|
+
> **CI**: `string` \| `undefined`
|
|
22
|
+
|
|
23
|
+
An indicator that the code is running in a Continuous Integration environment.
|
|
24
|
+
|
|
25
|
+
#### Example
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
"1"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### VERCEL
|
|
32
|
+
|
|
33
|
+
> **VERCEL**: `string` \| `undefined`
|
|
34
|
+
|
|
35
|
+
An indicator to show that System Environment Variables have been exposed to your project's Deployments.
|
|
36
|
+
|
|
37
|
+
#### Example
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
"1"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### VERCEL\_AUTOMATION\_BYPASS\_SECRET
|
|
44
|
+
|
|
45
|
+
> **VERCEL\_AUTOMATION\_BYPASS\_SECRET**: `string` \| `undefined`
|
|
46
|
+
|
|
47
|
+
The Protection Bypass for Automation value, if the secret has been generated in the project's Deployment Protection settings.
|
|
48
|
+
|
|
49
|
+
### VERCEL\_BRANCH\_URL
|
|
50
|
+
|
|
51
|
+
> **VERCEL\_BRANCH\_URL**: `string` \| `undefined`
|
|
52
|
+
|
|
53
|
+
The domain name of the generated Git branch URL. The value does not include the protocol scheme https://.
|
|
54
|
+
|
|
55
|
+
#### Example
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
"*-git-*.vercel.app"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### VERCEL\_DEPLOYMENT\_ID
|
|
62
|
+
|
|
63
|
+
> **VERCEL\_DEPLOYMENT\_ID**: `string` \| `undefined`
|
|
64
|
+
|
|
65
|
+
The unique identifier for the deployment, which can be used to implement Skew Protection.
|
|
66
|
+
|
|
67
|
+
#### Example
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
"dpl_7Gw5ZMBpQA8h9GF832KGp7nwbuh3"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### VERCEL\_ENV
|
|
74
|
+
|
|
75
|
+
> **VERCEL\_ENV**: `string` \| `undefined`
|
|
76
|
+
|
|
77
|
+
The Environment that the app is deployed and running on.
|
|
78
|
+
|
|
79
|
+
#### Example
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
"production"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### VERCEL\_GIT\_COMMIT\_AUTHOR\_LOGIN
|
|
86
|
+
|
|
87
|
+
> **VERCEL\_GIT\_COMMIT\_AUTHOR\_LOGIN**: `string` \| `undefined`
|
|
88
|
+
|
|
89
|
+
The username attached to the author of the commit that the project was deployed by.
|
|
90
|
+
|
|
91
|
+
#### Example
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
"johndoe"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### VERCEL\_GIT\_COMMIT\_AUTHOR\_NAME
|
|
98
|
+
|
|
99
|
+
> **VERCEL\_GIT\_COMMIT\_AUTHOR\_NAME**: `string` \| `undefined`
|
|
100
|
+
|
|
101
|
+
The name attached to the author of the commit that the project was deployed by.
|
|
102
|
+
|
|
103
|
+
#### Example
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
"John Doe"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### VERCEL\_GIT\_COMMIT\_MESSAGE
|
|
110
|
+
|
|
111
|
+
> **VERCEL\_GIT\_COMMIT\_MESSAGE**: `string` \| `undefined`
|
|
112
|
+
|
|
113
|
+
The message attached to the commit the deployment was triggered by.
|
|
114
|
+
|
|
115
|
+
#### Example
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
"Update about page"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### VERCEL\_GIT\_COMMIT\_REF
|
|
122
|
+
|
|
123
|
+
> **VERCEL\_GIT\_COMMIT\_REF**: `string` \| `undefined`
|
|
124
|
+
|
|
125
|
+
The git branch of the commit the deployment was triggered by.
|
|
126
|
+
|
|
127
|
+
#### Example
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
"improve-about-page"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### VERCEL\_GIT\_COMMIT\_SHA
|
|
134
|
+
|
|
135
|
+
> **VERCEL\_GIT\_COMMIT\_SHA**: `string` \| `undefined`
|
|
136
|
+
|
|
137
|
+
The git SHA of the commit the deployment was triggered by.
|
|
138
|
+
|
|
139
|
+
#### Example
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
"fa1eade47b73733d6312d5abfad33ce9e4068081"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### VERCEL\_GIT\_PREVIOUS\_SHA
|
|
146
|
+
|
|
147
|
+
> **VERCEL\_GIT\_PREVIOUS\_SHA**: `string` \| `undefined`
|
|
148
|
+
|
|
149
|
+
The git SHA of the last successful deployment for the project and branch.
|
|
150
|
+
NOTE: This Variable is only exposed when an Ignored Build Step is provided.
|
|
151
|
+
|
|
152
|
+
#### Example
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
"fa1eade47b73733d6312d5abfad33ce9e4068080"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### VERCEL\_GIT\_PROVIDER
|
|
159
|
+
|
|
160
|
+
> **VERCEL\_GIT\_PROVIDER**: `string` \| `undefined`
|
|
161
|
+
|
|
162
|
+
The Git Provider the deployment is triggered from.
|
|
163
|
+
|
|
164
|
+
#### Example
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
"github"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### VERCEL\_GIT\_PULL\_REQUEST\_ID
|
|
171
|
+
|
|
172
|
+
> **VERCEL\_GIT\_PULL\_REQUEST\_ID**: `string` \| `undefined`
|
|
173
|
+
|
|
174
|
+
The pull request id the deployment was triggered by. If a deployment is created on a branch before a pull request is made, this value will be an empty string.
|
|
175
|
+
|
|
176
|
+
#### Example
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
"23"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### VERCEL\_GIT\_REPO\_ID
|
|
183
|
+
|
|
184
|
+
> **VERCEL\_GIT\_REPO\_ID**: `string` \| `undefined`
|
|
185
|
+
|
|
186
|
+
The ID of the repository the deployment is triggered from.
|
|
187
|
+
|
|
188
|
+
#### Example
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
"117716146"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### VERCEL\_GIT\_REPO\_OWNER
|
|
195
|
+
|
|
196
|
+
> **VERCEL\_GIT\_REPO\_OWNER**: `string` \| `undefined`
|
|
197
|
+
|
|
198
|
+
The account that owns the repository the deployment is triggered from.
|
|
199
|
+
|
|
200
|
+
#### Example
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
"acme"
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### VERCEL\_GIT\_REPO\_SLUG
|
|
207
|
+
|
|
208
|
+
> **VERCEL\_GIT\_REPO\_SLUG**: `string` \| `undefined`
|
|
209
|
+
|
|
210
|
+
The origin repository the deployment is triggered from.
|
|
211
|
+
|
|
212
|
+
#### Example
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
"my-site"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### VERCEL\_PROJECT\_PRODUCTION\_URL
|
|
219
|
+
|
|
220
|
+
> **VERCEL\_PROJECT\_PRODUCTION\_URL**: `string` \| `undefined`
|
|
221
|
+
|
|
222
|
+
A production domain name of the project. This is useful to reliably generate links that point to production such as OG-image URLs.
|
|
223
|
+
The value does not include the protocol scheme https://.
|
|
224
|
+
|
|
225
|
+
#### Example
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
"myproject.vercel.app"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### VERCEL\_REGION
|
|
232
|
+
|
|
233
|
+
> **VERCEL\_REGION**: `string` \| `undefined`
|
|
234
|
+
|
|
235
|
+
The ID of the Region where the app is running.
|
|
236
|
+
|
|
237
|
+
Possible values:
|
|
238
|
+
- arn1 (Stockholm, Sweden)
|
|
239
|
+
- bom1 (Mumbai, India)
|
|
240
|
+
- cdg1 (Paris, France)
|
|
241
|
+
- cle1 (Cleveland, USA)
|
|
242
|
+
- cpt1 (Cape Town, South Africa)
|
|
243
|
+
- dub1 (Dublin, Ireland)
|
|
244
|
+
- fra1 (Frankfurt, Germany)
|
|
245
|
+
- gru1 (São Paulo, Brazil)
|
|
246
|
+
- hkg1 (Hong Kong)
|
|
247
|
+
- hnd1 (Tokyo, Japan)
|
|
248
|
+
- iad1 (Washington, D.C., USA)
|
|
249
|
+
- icn1 (Seoul, South Korea)
|
|
250
|
+
- kix1 (Osaka, Japan)
|
|
251
|
+
- lhr1 (London, United Kingdom)
|
|
252
|
+
- pdx1 (Portland, USA)
|
|
253
|
+
- sfo1 (San Francisco, USA)
|
|
254
|
+
- sin1 (Singapore)
|
|
255
|
+
- syd1 (Sydney, Australia)
|
|
256
|
+
- dev1 (Development Region)
|
|
257
|
+
|
|
258
|
+
#### Example
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
"iad1"
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### VERCEL\_SKEW\_PROTECTION\_ENABLED
|
|
265
|
+
|
|
266
|
+
> **VERCEL\_SKEW\_PROTECTION\_ENABLED**: `string` \| `undefined`
|
|
267
|
+
|
|
268
|
+
When Skew Protection is enabled in Project Settings, this value is set to 1.
|
|
269
|
+
|
|
270
|
+
#### Example
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
"1"
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### VERCEL\_URL
|
|
277
|
+
|
|
278
|
+
> **VERCEL\_URL**: `string` \| `undefined`
|
|
279
|
+
|
|
280
|
+
The domain name of the generated deployment URL. The value does not include the protocol scheme https://.
|
|
281
|
+
NOTE: This Variable cannot be used in conjunction with Standard Deployment Protection.
|
|
282
|
+
|
|
283
|
+
#### Example
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
"*.vercel.app"
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## See
|
|
290
|
+
|
|
291
|
+
https://vercel.com/docs/projects/environment-variables/system-environment-variables#system-environment-variables
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: invalidateBySrcImage()
|
|
6
|
+
|
|
7
|
+
> **invalidateBySrcImage**(`src`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/purge/index.ts:23](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L23)
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
### src
|
|
14
|
+
|
|
15
|
+
`string` \| `string`[]
|
|
16
|
+
|
|
17
|
+
## Returns
|
|
18
|
+
|
|
19
|
+
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: invalidateByTag()
|
|
6
|
+
|
|
7
|
+
> **invalidateByTag**(`tag`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/purge/index.ts:4](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/index.ts#L4)
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
### tag
|
|
14
|
+
|
|
15
|
+
`string` \| `string`[]
|
|
16
|
+
|
|
17
|
+
## Returns
|
|
18
|
+
|
|
19
|
+
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: ipAddress()
|
|
6
|
+
|
|
7
|
+
> **ipAddress**(`input`): `string` \| `undefined`
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/headers.ts:131](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L131)
|
|
10
|
+
|
|
11
|
+
Returns the IP address of the request from the headers.
|
|
12
|
+
|
|
13
|
+
## Parameters
|
|
14
|
+
|
|
15
|
+
### input
|
|
16
|
+
|
|
17
|
+
`Headers` \| [`Request`](../interfaces/Request.md)
|
|
18
|
+
|
|
19
|
+
The incoming request object or headers.
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
`string` \| `undefined`
|
|
24
|
+
|
|
25
|
+
The IP address of the request.
|
|
26
|
+
|
|
27
|
+
## Example
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { ipAddress } from '@vercel/functions';
|
|
31
|
+
|
|
32
|
+
export function GET(request) {
|
|
33
|
+
const ip = ipAddress(request);
|
|
34
|
+
return new Response(`Your IP is ${ip}`);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# Function: next()
|
|
6
|
+
|
|
7
|
+
> **next**(`init?`): [`Response`](https://developer.mozilla.org/docs/Web/API/Response)
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/middleware.ts:145](https://github.com/vercel/vercel/blob/main/packages/functions/src/middleware.ts#L145)
|
|
10
|
+
|
|
11
|
+
Returns a Response that instructs the system to continue processing the request.
|
|
12
|
+
|
|
13
|
+
## Parameters
|
|
14
|
+
|
|
15
|
+
### init?
|
|
16
|
+
|
|
17
|
+
`ExtraResponseInit`
|
|
18
|
+
|
|
19
|
+
Additional options for the response
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
[`Response`](https://developer.mozilla.org/docs/Web/API/Response)
|
|
24
|
+
|
|
25
|
+
## Examples
|
|
26
|
+
|
|
27
|
+
<caption>No-op middleware</caption>
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { next } from '@vercel/edge';
|
|
31
|
+
|
|
32
|
+
export default function middleware(_req: Request) {
|
|
33
|
+
return next();
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
<caption>Add response headers to all requests</caption>
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { next } from '@vercel/edge';
|
|
41
|
+
|
|
42
|
+
export default function middleware(_req: Request) {
|
|
43
|
+
return next({
|
|
44
|
+
headers: { 'x-from-middleware': 'true' },
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
```
|