@jaypie/mcp 0.7.3 → 0.7.4
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/dist/suites/docs/index.js +1 -1
- package/package.json +1 -1
- package/release-notes/express/1.2.7.md +48 -0
- package/skills/cors.md +30 -0
|
@@ -9,7 +9,7 @@ import { gt } from 'semver';
|
|
|
9
9
|
/**
|
|
10
10
|
* Docs Suite - Documentation services (skill, version, release_notes)
|
|
11
11
|
*/
|
|
12
|
-
const BUILD_VERSION_STRING = "@jaypie/mcp@0.7.
|
|
12
|
+
const BUILD_VERSION_STRING = "@jaypie/mcp@0.7.4#9b2629b2"
|
|
13
13
|
;
|
|
14
14
|
const __filename$1 = fileURLToPath(import.meta.url);
|
|
15
15
|
const __dirname$1 = path.dirname(__filename$1);
|
package/package.json
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
version: 1.2.7
|
|
3
|
+
date: 2025-01-30
|
|
4
|
+
summary: Fix CORS OPTIONS preflight hanging with Lambda streaming
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Bug Fix
|
|
8
|
+
|
|
9
|
+
Fixed an issue where CORS OPTIONS preflight requests would hang indefinitely when using `createLambdaStreamHandler` with the `cors` middleware.
|
|
10
|
+
|
|
11
|
+
### Problem
|
|
12
|
+
|
|
13
|
+
When using Lambda response streaming, browser CORS preflight (OPTIONS) requests would hang because:
|
|
14
|
+
- The standard cors package's call to `res.end()` could get delayed by streaming's async behavior
|
|
15
|
+
- The Lambda response stream would stay open waiting for streaming data that never comes
|
|
16
|
+
- Browsers would timeout waiting for the preflight response
|
|
17
|
+
|
|
18
|
+
### Solution
|
|
19
|
+
|
|
20
|
+
The `cors` middleware now detects OPTIONS requests early and handles them synchronously:
|
|
21
|
+
- Sets all required CORS headers directly (Access-Control-Allow-Origin, Access-Control-Allow-Methods, etc.)
|
|
22
|
+
- Terminates the response immediately with a 204 No Content status
|
|
23
|
+
- Ensures the response stream doesn't enter streaming mode for preflight requests
|
|
24
|
+
|
|
25
|
+
### Usage
|
|
26
|
+
|
|
27
|
+
No changes required. The fix is automatic when using `cors` with `createLambdaStreamHandler`:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import express from "express";
|
|
31
|
+
import { cors, createLambdaStreamHandler } from "@jaypie/express";
|
|
32
|
+
|
|
33
|
+
const app = express();
|
|
34
|
+
app.use(cors({ origin: "https://example.com" }));
|
|
35
|
+
|
|
36
|
+
// Streaming endpoint works correctly with CORS
|
|
37
|
+
app.post("/stream", (req, res) => {
|
|
38
|
+
res.setHeader("Content-Type", "text/event-stream");
|
|
39
|
+
res.write("data: hello\n\n");
|
|
40
|
+
res.end();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const handler = createLambdaStreamHandler(app);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Related
|
|
47
|
+
|
|
48
|
+
- GitHub Issue: [#174](https://github.com/finlaysonstudio/jaypie/issues/174)
|
package/skills/cors.md
CHANGED
|
@@ -317,6 +317,36 @@ app.use(cors({
|
|
|
317
317
|
| `PROJECT_ENV` | Set to `sandbox` to enable localhost access |
|
|
318
318
|
| `PROJECT_SANDBOX_MODE` | Set to `true` to enable localhost access |
|
|
319
319
|
|
|
320
|
+
## Lambda Streaming Compatibility
|
|
321
|
+
|
|
322
|
+
Jaypie's `cors` middleware is designed to work seamlessly with Lambda response streaming (`createLambdaStreamHandler`). Unlike the standard `cors` package, Jaypie's implementation handles OPTIONS preflight requests early and terminates them immediately, preventing the response stream from hanging.
|
|
323
|
+
|
|
324
|
+
This is critical because:
|
|
325
|
+
- Browser CORS preflight requests (OPTIONS) must complete quickly with a 204 response
|
|
326
|
+
- Lambda streaming keeps the response stream open for streaming data
|
|
327
|
+
- Without early termination, OPTIONS requests would hang waiting for streaming data that never comes
|
|
328
|
+
|
|
329
|
+
No special configuration is needed—Jaypie's `cors` automatically detects OPTIONS requests and handles them appropriately.
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
import express from "express";
|
|
333
|
+
import { cors, createLambdaStreamHandler } from "@jaypie/express";
|
|
334
|
+
|
|
335
|
+
const app = express();
|
|
336
|
+
|
|
337
|
+
// CORS works automatically with streaming
|
|
338
|
+
app.use(cors({ origin: "https://example.com" }));
|
|
339
|
+
|
|
340
|
+
app.post("/stream", (req, res) => {
|
|
341
|
+
res.setHeader("Content-Type", "text/event-stream");
|
|
342
|
+
res.write("data: hello\n\n");
|
|
343
|
+
res.end();
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
// Deploy with Lambda streaming - CORS preflight works correctly
|
|
347
|
+
export const handler = createLambdaStreamHandler(app);
|
|
348
|
+
```
|
|
349
|
+
|
|
320
350
|
## See Also
|
|
321
351
|
|
|
322
352
|
- **`skill("express")`** - Express handler and Lambda adapter documentation
|