Skip to content

Commit 7e1f2fe

Browse files
authored
Merge pull request #5378 from remotion-dev/copilot/fix-55bffa9b-25ec-4d77-b541-9b44d7f6005c
2 parents 93351f6 + edf34a0 commit 7e1f2fe

File tree

100 files changed

+767
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+767
-59
lines changed

bun.lock

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"lockfileVersion": 1,
3+
"workspaces": {
4+
"": {
5+
"name": "remotion-monorepo",
6+
"dependencies": {
7+
"turbo": "2.4.4",
8+
"typescript": "5.8.2",
9+
},
10+
"devDependencies": {
11+
"@types/bun": "1.2.8",
12+
"@types/deno": "2.0.0",
13+
"@types/react": "19.0.0",
14+
"@types/react-dom": "19.0.0",
15+
"prettier": "3.3.3",
16+
"prettier-plugin-organize-imports": "3.2.4",
17+
},
18+
},
19+
},
20+
"packages": {
21+
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.2.7" } }, "sha512-t8L1RvJVUghW5V+M/fL3Thbxcs0HwNsXsnTEBEfEVqGteiJToOlZ/fyOEaR1kZsNqnu+3XA4RI/qmnX4w6+S+w=="],
22+
23+
"@types/deno": ["@types/[email protected]", "", {}, "sha512-O9/jRVlq93kqfkl4sYR5N7+Pz4ukzXVIbMnE/VgvpauNHsvjQ9iBVnJ3X0gAvMa2khcoFD8DSO7mQVCuiuDMPg=="],
24+
25+
"@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-MX4Zioh39chHlDJbKmEgydJDS3tspMP/lnQC67G3SWsTnb9NeYVWOjkxpOSy4oMfPs4StcWHwBrvUb4ybfnuaw=="],
26+
27+
"@types/react": ["@types/[email protected]", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-MY3oPudxvMYyesqs/kW1Bh8y9VqSmf+tzqw3ae8a9DZW68pUe3zAdHeI1jc6iAysuRdACnVknHP8AhwD4/dxtg=="],
28+
29+
"@types/react-dom": ["@types/[email protected]", "", { "dependencies": { "@types/react": "*" } }, "sha512-1KfiQKsH1o00p9m5ag12axHQSb3FOU9H20UTrujVSkNhuCrRHiQWFqgEnTNK5ZNfnzZv8UWrnXVqCmCF9fgY3w=="],
30+
31+
"@types/ws": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
32+
33+
"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*", "@types/ws": "*" } }, "sha512-P4hHhk7kjF99acXqKvltyuMQ2kf/rzIw3ylEDpCxDS9Xa0X0Yp/gJu/vDCucmWpiur5qJ0lwB2bWzOXa2GlHqA=="],
34+
35+
"csstype": ["[email protected]", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
36+
37+
"prettier": ["[email protected]", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew=="],
38+
39+
"prettier-plugin-organize-imports": ["[email protected]", "", { "peerDependencies": { "@volar/vue-language-plugin-pug": "^1.0.4", "@volar/vue-typescript": "^1.0.4", "prettier": ">=2.0", "typescript": ">=2.9" }, "optionalPeers": ["@volar/vue-language-plugin-pug", "@volar/vue-typescript"] }, "sha512-6m8WBhIp0dfwu0SkgfOxJqh+HpdyfqSSLfKKRZSFbDuEQXDDndb8fTpRWkUrX/uBenkex3MgnVk0J3b3Y5byog=="],
40+
41+
"turbo": ["[email protected]", "", { "optionalDependencies": { "turbo-darwin-64": "2.4.4", "turbo-darwin-arm64": "2.4.4", "turbo-linux-64": "2.4.4", "turbo-linux-arm64": "2.4.4", "turbo-windows-64": "2.4.4", "turbo-windows-arm64": "2.4.4" }, "bin": { "turbo": "bin/turbo" } }, "sha512-N9FDOVaY3yz0YCOhYIgOGYad7+m2ptvinXygw27WPLQvcZDl3+0Sa77KGVlLSiuPDChOUEnTKE9VJwLSi9BPGQ=="],
42+
43+
"turbo-darwin-64": ["[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-5kPvRkLAfmWI0MH96D+/THnDMGXlFNmjeqNRj5grLKiry+M9pKj3pRuScddAXPdlxjO5Ptz06UNaOQrrYGTx1g=="],
44+
45+
"turbo-darwin-arm64": ["[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-/gtHPqbGQXDFhrmy+Q/MFW2HUTUlThJ97WLLSe4bxkDrKHecDYhAjbZ4rN3MM93RV9STQb3Tqy4pZBtsd4DfCw=="],
46+
47+
"turbo-linux-64": ["[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-SR0gri4k0bda56hw5u9VgDXLKb1Q+jrw4lM7WAhnNdXvVoep4d6LmnzgMHQQR12Wxl3KyWPbkz9d1whL6NTm2Q=="],
48+
49+
"turbo-linux-arm64": ["[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-COXXwzRd3vslQIfJhXUklgEqlwq35uFUZ7hnN+AUyXx7hUOLIiD5NblL+ETrHnhY4TzWszrbwUMfe2BYWtaPQg=="],
50+
51+
"turbo-windows-64": ["[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-PV9rYNouGz4Ff3fd6sIfQy5L7HT9a4fcZoEv8PKRavU9O75G7PoDtm8scpHU10QnK0QQNLbE9qNxOAeRvF0fJg=="],
52+
53+
"turbo-windows-arm64": ["[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-403sqp9t5sx6YGEC32IfZTVWkRAixOQomGYB8kEc6ZD+//LirSxzeCHCnM8EmSXw7l57U1G+Fb0kxgTcKPU/Lg=="],
54+
55+
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ=="],
56+
57+
"undici-types": ["[email protected]", "", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="],
58+
}
59+
}

packages/docs/docs/lambda/proxy.mdx

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
image: /generated/articles-docs-lambda-proxy.png
3+
id: proxy
4+
title: Using a proxy with Remotion Lambda
5+
sidebar_label: Using a proxy
6+
crumb: 'Lambda'
7+
---
8+
9+
_Available from v4.0.315_
10+
11+
Remotion Lambda supports using HTTP/HTTPS proxies for all AWS API calls by accepting a `requestHandler` option that allows you to pass a custom AWS SDK request handler.
12+
13+
This is useful when your environment requires all external HTTP requests to go through a proxy server.
14+
15+
## Setting up a proxy
16+
17+
### 1. Install a proxy agent
18+
19+
First, install an HTTP/HTTPS proxy agent package like `https-proxy-agent`:
20+
21+
```bash
22+
npm install https-proxy-agent
23+
```
24+
25+
### 2. Create a request handler with proxy
26+
27+
Create a request handler that uses your proxy:
28+
29+
```tsx twoslash
30+
import {HttpsProxyAgent} from 'https-proxy-agent';
31+
32+
// Configure your proxy URL
33+
const proxyUrl = 'http://your-proxy-server:8080';
34+
35+
// Create a proxy agent
36+
const proxyAgent = new HttpsProxyAgent(proxyUrl);
37+
38+
// Create a request handler that uses the proxy
39+
export const proxyRequestHandler = {
40+
httpsAgent: proxyAgent,
41+
};
42+
```
43+
44+
### 3. Use the request handler with Remotion Lambda functions
45+
46+
Pass the `requestHandler` option to any Remotion Lambda function:
47+
48+
```tsx twoslash
49+
// @filename: proxy-setup.ts
50+
import {HttpsProxyAgent} from 'https-proxy-agent';
51+
52+
const proxyUrl = 'http://your-proxy-server:8080';
53+
const proxyAgent = new HttpsProxyAgent(proxyUrl);
54+
55+
export const proxyRequestHandler = {
56+
httpsAgent: proxyAgent,
57+
};
58+
59+
// @filename: example.ts
60+
// ---cut---
61+
import {getFunctions} from '@remotion/lambda/client';
62+
import {proxyRequestHandler} from './proxy-setup';
63+
64+
const functions = await getFunctions({
65+
region: 'us-east-1',
66+
compatibleOnly: true,
67+
requestHandler: proxyRequestHandler,
68+
});
69+
70+
console.log('Functions:', functions);
71+
```
72+
73+
## Supported functions
74+
75+
All public AWS-related APIs in the Lambda client accept the `requestHandler` option.
76+
77+
## Example with authentication
78+
79+
If your proxy requires authentication, you can include credentials in the proxy URL:
80+
81+
```tsx twoslash
82+
import {HttpsProxyAgent} from 'https-proxy-agent';
83+
84+
// Proxy with authentication
85+
const proxyUrl = 'http://username:password@your-proxy-server:8080';
86+
const proxyAgent = new HttpsProxyAgent(proxyUrl);
87+
88+
export const authenticatedProxyRequestHandler = {
89+
httpsAgent: proxyAgent,
90+
};
91+
```
92+
93+
## TypeScript support
94+
95+
Remotion Lambda exports a `RequestHandler` type that you can use for type safety:
96+
97+
```tsx twoslash
98+
import type {RequestHandler} from '@remotion/lambda/client';
99+
import {HttpsProxyAgent} from 'https-proxy-agent';
100+
101+
const proxyAgent = new HttpsProxyAgent('http://proxy:8080');
102+
103+
const myRequestHandler: RequestHandler = {
104+
httpsAgent: proxyAgent,
105+
};
106+
```
107+
108+
## Environment-specific configuration
109+
110+
You can conditionally use a proxy based on your environment:
111+
112+
```tsx twoslash
113+
import {HttpsProxyAgent} from 'https-proxy-agent';
114+
import type {RequestHandler} from '@remotion/lambda/client';
115+
116+
const createRequestHandler = (): RequestHandler | undefined => {
117+
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
118+
119+
if (proxyUrl) {
120+
return {
121+
httpsAgent: new HttpsProxyAgent(proxyUrl),
122+
};
123+
}
124+
125+
// Return undefined to use default behavior
126+
return undefined;
127+
};
128+
129+
export const requestHandler = createRequestHandler();
130+
```
131+
132+
Then use it in your Lambda calls:
133+
134+
```tsx twoslash
135+
// @filename: conditional-proxy.ts
136+
import {HttpsProxyAgent} from 'https-proxy-agent';
137+
import type {RequestHandler} from '@remotion/lambda/client';
138+
139+
const createRequestHandler = (): RequestHandler | undefined => {
140+
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
141+
142+
if (proxyUrl) {
143+
return {
144+
httpsAgent: new HttpsProxyAgent(proxyUrl),
145+
};
146+
}
147+
148+
return undefined;
149+
};
150+
151+
export const requestHandler = createRequestHandler();
152+
153+
// @filename: usage.ts
154+
// ---cut---
155+
import {getFunctions} from '@remotion/lambda/client';
156+
import {requestHandler} from './conditional-proxy';
157+
158+
const functions = await getFunctions({
159+
region: 'us-east-1',
160+
compatibleOnly: true,
161+
requestHandler, // This will be undefined if no proxy is configured
162+
});
163+
```
164+
165+
## See also
166+
167+
- [https-proxy-agent documentation](https://www.npmjs.com/package/https-proxy-agent)
168+
- [getFunctions()](/docs/lambda/getfunctions)
169+
- [getAwsClient()](/docs/lambda/getawsclient)

packages/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"three": "0.158.0",
9797
"uuid": "^8.3.2",
9898
"zod": "3.22.3",
99+
"https-proxy-agent": "^7.0.2",
99100
"@remotion/eslint-config-internal": "workspace:*",
100101
"eslint": "9.19.0"
101102
},

packages/docs/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ module.exports = {
995995
'lambda/bucket-naming',
996996
'lambda/optimizing-cost',
997997
'lambda/optimizing-speed',
998+
'lambda/proxy',
998999
'lambda/limits',
9991000
'lambda/changelog',
10001001
'lambda/upgrading',

packages/docs/src/data/articles.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,6 +2258,15 @@ export const articles = [
22582258
noAi: false,
22592259
slug: 'lambda/presignurl',
22602260
},
2261+
{
2262+
id: 'proxy',
2263+
title: 'Using a proxy with Remotion Lambda',
2264+
relativePath: 'docs/lambda/proxy.mdx',
2265+
compId: 'articles-docs-lambda-proxy',
2266+
crumb: 'Lambda',
2267+
noAi: false,
2268+
slug: 'lambda/proxy',
2269+
},
22612270
{
22622271
id: 'lambda/python',
22632272
title: 'Triggering renders from Python',
Loading

packages/it-tests/src/monorepo/go-package.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ test(
8282
},
8383
apiKey: null,
8484
storageClass: null,
85+
requestHandler: null,
8586
});
8687

8788
expect(removeUndefined(parsed)).toEqual(removeUndefined(nativeVersion));

packages/it-tests/src/monorepo/php-package.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class Semantic
127127
},
128128
apiKey: null,
129129
storageClass: null,
130+
requestHandler: null,
130131
});
131132
const jsonOutput = toParse.substring(0, toParse.lastIndexOf('}') + 1);
132133
const parsedJson = JSON.parse(jsonOutput);

packages/it-tests/src/monorepo/python-package.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ test('Python package should create the same renderMedia payload as normal Lambda
4949
const toParse = output[PYTHON_OUTPUT_MARKER];
5050
const nativeVersion =
5151
await LambdaClientInternals.makeLambdaRenderMediaPayload({
52+
requestHandler: null,
5253
region: 'us-east-1',
5354
composition: 'react-svg',
5455
functionName: 'remotion-render',
@@ -193,6 +194,7 @@ test('Python package should create the same renderStill payload as normal Lambda
193194
forcePathStyle: false,
194195
apiKey: null,
195196
storageClass: null,
197+
requestHandler: null,
196198
});
197199
const jsonOutput = toParse.substring(0, toParse.lastIndexOf('}') + 1);
198200
const {streamed: _, ...parsedJson} = JSON.parse(jsonOutput);

packages/it-tests/src/monorepo/ruby-package.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ test('Render Media payload', async () => {
134134
},
135135
apiKey: null,
136136
storageClass: null,
137+
requestHandler: null,
137138
});
138139

139140
expect(JSON.parse(output)).toEqual(nativeVersion);
@@ -178,6 +179,7 @@ test('Render Still payload', async () => {
178179
apiKey: null,
179180
offthreadVideoThreads: null,
180181
storageClass: null,
182+
requestHandler: null,
181183
});
182184

183185
expect(JSON.parse(output)).toEqual({...nativeVersion, streamed: false});

packages/lambda-client/src/aws-clients.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,71 @@ import type {ServiceQuotasClient} from '@aws-sdk/client-service-quotas';
55
import type {STSClient} from '@aws-sdk/client-sts';
66
import {getServiceClient} from './get-service-client';
77
import type {AwsRegion} from './regions';
8+
import type {RequestHandler} from './types';
89

910
export const getCloudWatchLogsClient = (
1011
region: AwsRegion,
12+
requestHandler: RequestHandler | null,
1113
): CloudWatchLogsClient => {
1214
return getServiceClient({
1315
region,
1416
service: 'cloudwatch',
1517
customCredentials: null,
1618
forcePathStyle: false,
19+
requestHandler,
1720
});
1821
};
1922

2023
export const getLambdaClient = (
2124
region: AwsRegion,
2225
// eslint-disable-next-line @typescript-eslint/no-unused-vars
23-
_timeoutInTest?: number,
26+
_timeoutInTest: number | undefined,
27+
requestHandler: RequestHandler | null,
2428
): LambdaClient => {
2529
return getServiceClient({
2630
region,
2731
service: 'lambda',
2832
customCredentials: null,
2933
forcePathStyle: false,
34+
requestHandler,
3035
});
3136
};
3237

33-
export const getIamClient = (region: AwsRegion): IAMClient => {
38+
export const getIamClient = (
39+
region: AwsRegion,
40+
requestHandler: RequestHandler | null,
41+
): IAMClient => {
3442
return getServiceClient({
3543
region,
3644
service: 'iam',
3745
customCredentials: null,
3846
forcePathStyle: false,
47+
requestHandler,
3948
});
4049
};
4150

4251
export const getServiceQuotasClient = (
4352
region: AwsRegion,
53+
requestHandler: RequestHandler | null,
4454
): ServiceQuotasClient => {
4555
return getServiceClient({
4656
region,
4757
service: 'servicequotas',
4858
customCredentials: null,
4959
forcePathStyle: false,
60+
requestHandler,
5061
});
5162
};
5263

53-
export const getStsClient = (region: AwsRegion): STSClient => {
64+
export const getStsClient = (
65+
region: AwsRegion,
66+
requestHandler: RequestHandler | null,
67+
): STSClient => {
5468
return getServiceClient({
5569
region,
5670
service: 'sts',
5771
customCredentials: null,
5872
forcePathStyle: false,
73+
requestHandler,
5974
});
6075
};

0 commit comments

Comments
 (0)