@gasket/plugin-https-proxy 7.3.9 → 7.3.10
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 +40 -1
- package/cjs/actions.js +1 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +5 -0
- package/lib/actions.js +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Create an HTTPS proxy server with Gasket to use as a sidecar for frameworks that
|
|
4
4
|
do not handle HTTPS, such as Next.js. This can be useful for local development
|
|
5
|
-
when you want to test HTTPS features and use secure cookies for
|
|
5
|
+
when you want to test HTTPS features and use secure cookies for
|
|
6
6
|
authentication, etc.
|
|
7
7
|
It can also be used in production if it is necessary for your application to
|
|
8
8
|
handle HTTPS requests on the container.
|
|
@@ -102,8 +102,47 @@ import gasket from './gasket.js';
|
|
|
102
102
|
gasket.actions.startProxyServer();
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
|
|
106
|
+
The complete flow is:
|
|
107
|
+
|
|
108
|
+
1. Waits for `gasket.isReady` (ensuring async configuration is complete)
|
|
109
|
+
2. Executes the `prebootHttpsProxy` lifecycle (one-time initialization)
|
|
110
|
+
3. Executes the `httpsProxy` lifecycle for dynamic configuration
|
|
111
|
+
4. Creates and starts the proxy server
|
|
105
112
|
## Lifecycles
|
|
106
113
|
|
|
114
|
+
### prebootHttpsProxy
|
|
115
|
+
|
|
116
|
+
This lifecycle is executed before the proxy server is started. It is a good place to
|
|
117
|
+
execute operations that need to happen before the proxy server is started.
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
/**
|
|
121
|
+
* Executed before the proxy server is started.
|
|
122
|
+
*
|
|
123
|
+
* @param {Gasket} gasket Gasket API.
|
|
124
|
+
*/
|
|
125
|
+
prebootHttpsProxy: async function prebootHttpsProxy(gasket) {
|
|
126
|
+
// async operations
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### When to use `prebootHttpsProxy` vs `prepare`
|
|
131
|
+
|
|
132
|
+
The `preboot` lifecycle runs **once** when the proxy server starts, while the `prepare` lifecycle runs for **every** Gasket instance creation. Use `preboot` for:
|
|
133
|
+
|
|
134
|
+
- One-time proxy server initialization
|
|
135
|
+
- Setting up shared SSL/TLS contexts
|
|
136
|
+
- Loading certificates that will be reused across requests
|
|
137
|
+
- Establishing persistent connections or pools
|
|
138
|
+
|
|
139
|
+
Use `prepare` for:
|
|
140
|
+
|
|
141
|
+
- Per-instance configuration
|
|
142
|
+
- Setting up instance-specific state
|
|
143
|
+
- Operations that need fresh initialization for each Gasket instance
|
|
144
|
+
|
|
145
|
+
> **Note**: In SSR applications, new Gasket instances may be created for different contexts, causing `prepare` to run multiple times. For proxy servers, this can lead to unnecessary overhead. Use `preboot` for expensive initialization operations.
|
|
107
146
|
### httpsProxy
|
|
108
147
|
|
|
109
148
|
While most settings can be configured in the `httpsProxy` configuration,
|
package/cjs/actions.js
CHANGED
|
@@ -84,6 +84,7 @@ function startProxyServer(gasket) {
|
|
|
84
84
|
function _startProxyServer() {
|
|
85
85
|
_startProxyServer = _async_to_generator(function*(gasket) {
|
|
86
86
|
yield gasket.isReady;
|
|
87
|
+
yield gasket.exec('prebootHttpsProxy');
|
|
87
88
|
const { httpsProxy } = gasket.config;
|
|
88
89
|
const { logger } = gasket;
|
|
89
90
|
const opts = yield gasket.execWaterfall('httpsProxy', httpsProxy);
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
package/lib/actions.js
CHANGED
|
@@ -3,6 +3,7 @@ import proxy from 'http-proxy';
|
|
|
3
3
|
/** @type {import('@gasket/core').ActionHandler<'startProxyServer'>} */
|
|
4
4
|
export async function startProxyServer(gasket) {
|
|
5
5
|
await gasket.isReady;
|
|
6
|
+
await gasket.exec('prebootHttpsProxy');
|
|
6
7
|
const { httpsProxy } = gasket.config;
|
|
7
8
|
const { logger } = gasket;
|
|
8
9
|
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gasket/plugin-https-proxy",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.10",
|
|
4
4
|
"description": "Adds support for running an https proxy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"typescript": "^5.8.2",
|
|
48
48
|
"vitest": "^3.2.0",
|
|
49
49
|
"@gasket/core": "7.5.0",
|
|
50
|
+
"@gasket/plugin-https": "7.3.6",
|
|
50
51
|
"@gasket/plugin-logger": "7.3.4",
|
|
51
52
|
"@gasket/plugin-metadata": "7.4.2",
|
|
52
|
-
"create-gasket-app": "7.4.
|
|
53
|
-
"@gasket/plugin-https": "7.3.5"
|
|
53
|
+
"create-gasket-app": "7.4.4"
|
|
54
54
|
},
|
|
55
55
|
"eslintConfig": {
|
|
56
56
|
"extends": [
|