starlight-server 1.9.2 → 1.9.3
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/http/cors.js +1 -1
- package/dist/http/response.js +1 -0
- package/package.json +1 -1
- package/src/http/cors.ts +1 -1
- package/src/http/response.ts +1 -0
- package/src/router/index.ts +1 -0
package/dist/http/cors.js
CHANGED
|
@@ -11,7 +11,7 @@ export function isPreflight(request) {
|
|
|
11
11
|
* 否则返回 null
|
|
12
12
|
*/
|
|
13
13
|
export function getPreflightRequestMethod(request) {
|
|
14
|
-
return isPreflight(request) ? request.headers['access-control-request-method'] ?? '' : null;
|
|
14
|
+
return isPreflight(request) ? (request.headers['access-control-request-method'] ?? '') : null;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* 输出 CORS 相关 headers
|
package/dist/http/response.js
CHANGED
|
@@ -60,6 +60,7 @@ export class ResponseUtils {
|
|
|
60
60
|
error(error) {
|
|
61
61
|
if (error instanceof HTTPError) {
|
|
62
62
|
this.nodeResponse.statusCode = error.status;
|
|
63
|
+
this.nodeResponse.setHeader('Content-Type', 'text/plain; charset=UTF-8');
|
|
63
64
|
this.nodeResponse.end(error.message);
|
|
64
65
|
}
|
|
65
66
|
else if (typeof error === 'number') {
|
package/package.json
CHANGED
package/src/http/cors.ts
CHANGED
|
@@ -20,7 +20,7 @@ export function isPreflight(request: Request | NodeRequest) {
|
|
|
20
20
|
* 否则返回 null
|
|
21
21
|
*/
|
|
22
22
|
export function getPreflightRequestMethod(request: Request | NodeRequest) {
|
|
23
|
-
return isPreflight(request) ? request.headers['access-control-request-method'] ?? '' : null
|
|
23
|
+
return isPreflight(request) ? (request.headers['access-control-request-method'] ?? '') : null
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
package/src/http/response.ts
CHANGED
|
@@ -64,6 +64,7 @@ export class ResponseUtils {
|
|
|
64
64
|
error(error: unknown) {
|
|
65
65
|
if (error instanceof HTTPError) {
|
|
66
66
|
this.nodeResponse.statusCode = error.status
|
|
67
|
+
this.nodeResponse.setHeader('Content-Type', 'text/plain; charset=UTF-8')
|
|
67
68
|
this.nodeResponse.end(error.message)
|
|
68
69
|
} else if (typeof error === 'number') {
|
|
69
70
|
this.error(new HTTPError(error))
|