@lowerdeck/rpc-server 1.0.4 → 1.0.6

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/rpcMux.ts +15 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowerdeck/rpc-server",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,9 +36,9 @@
36
36
  "vitest": "^3.2.4"
37
37
  },
38
38
  "dependencies": {
39
- "@lowerdeck/error": "^1.0.8",
39
+ "@lowerdeck/error": "^1.0.10",
40
40
  "@lowerdeck/execution-context": "^1.0.2",
41
- "@lowerdeck/id": "^1.0.5",
41
+ "@lowerdeck/id": "^1.0.6",
42
42
  "@lowerdeck/memo": "^1.0.4",
43
43
  "@lowerdeck/sentry": "^1.0.2",
44
44
  "@lowerdeck/serialize": "^1.0.4",
package/src/rpcMux.ts CHANGED
@@ -104,6 +104,21 @@ export let rpcMux = (
104
104
  return new Response(null, { status: 403 });
105
105
  }
106
106
 
107
+ let contentType = req.headers.get('content-type') ?? '';
108
+ if (
109
+ !contentType.includes('application/rpc+json') &&
110
+ !contentType.includes('application/json')
111
+ ) {
112
+ return new Response(
113
+ JSON.stringify(
114
+ notAcceptableError({
115
+ message: 'Content-Type must be application/rpc+json'
116
+ }).toResponse()
117
+ ),
118
+ { status: 406, headers: corsHeaders }
119
+ );
120
+ }
121
+
107
122
  let body: any = null;
108
123
 
109
124
  try {