@rest-vir/run-service 0.5.2 → 0.5.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.
|
@@ -31,7 +31,7 @@ export async function handleCors({ route, request, }) {
|
|
|
31
31
|
}
|
|
32
32
|
else if (matchedOrigin) {
|
|
33
33
|
return {
|
|
34
|
-
headers: buildStandardCorsHeaders(matchedOrigin),
|
|
34
|
+
headers: buildStandardCorsHeaders(matchedOrigin, route.service.customHeaders),
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
@@ -42,10 +42,14 @@ export async function handleCors({ route, request, }) {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
function buildStandardCorsHeaders(matchedOrigin) {
|
|
45
|
+
function buildStandardCorsHeaders(matchedOrigin, customHeaders) {
|
|
46
46
|
if (isAnyOrigin(matchedOrigin)) {
|
|
47
47
|
return {
|
|
48
48
|
'Access-Control-Allow-Origin': '*',
|
|
49
|
+
'Access-Control-Expose-Headers': [
|
|
50
|
+
restVirServiceNameHeader,
|
|
51
|
+
...customHeaders,
|
|
52
|
+
].join(','),
|
|
49
53
|
};
|
|
50
54
|
}
|
|
51
55
|
else {
|
|
@@ -53,6 +57,10 @@ function buildStandardCorsHeaders(matchedOrigin) {
|
|
|
53
57
|
'Access-Control-Allow-Origin': matchedOrigin,
|
|
54
58
|
'Access-Control-Allow-Credentials': 'true',
|
|
55
59
|
Vary: 'Origin',
|
|
60
|
+
'Access-Control-Expose-Headers': [
|
|
61
|
+
restVirServiceNameHeader,
|
|
62
|
+
...customHeaders,
|
|
63
|
+
].join(','),
|
|
56
64
|
};
|
|
57
65
|
}
|
|
58
66
|
}
|
|
@@ -69,7 +77,7 @@ function buildOptionsRequestCorsHeaders(matchedOrigin, allowedMethods, customHea
|
|
|
69
77
|
return contentLengthHeaders;
|
|
70
78
|
}
|
|
71
79
|
return {
|
|
72
|
-
...buildStandardCorsHeaders(matchedOrigin),
|
|
80
|
+
...buildStandardCorsHeaders(matchedOrigin, customHeaders),
|
|
73
81
|
'Access-Control-Allow-Methods': [
|
|
74
82
|
allowedMethods,
|
|
75
83
|
HttpMethod.Options,
|
|
@@ -80,10 +88,6 @@ function buildOptionsRequestCorsHeaders(matchedOrigin, allowedMethods, customHea
|
|
|
80
88
|
'Content-Type',
|
|
81
89
|
...customHeaders,
|
|
82
90
|
].join(','),
|
|
83
|
-
'Access-Control-Expose-Headers': [
|
|
84
|
-
restVirServiceNameHeader,
|
|
85
|
-
...customHeaders,
|
|
86
|
-
].join(','),
|
|
87
91
|
'Access-Control-Max-Age': accessControlMaxAgeValue,
|
|
88
92
|
...contentLengthHeaders,
|
|
89
93
|
};
|
|
@@ -35,6 +35,7 @@ export async function handleEndpointRequest({ endpoint, request, response, attac
|
|
|
35
35
|
return {
|
|
36
36
|
statusCode: endpointResult.statusCode,
|
|
37
37
|
body: endpointResult.responseErrorMessage,
|
|
38
|
+
headers: endpointResult.headers,
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
else if (endpointResult.responseData) {
|
|
@@ -45,6 +46,7 @@ export async function handleEndpointRequest({ endpoint, request, response, attac
|
|
|
45
46
|
return {
|
|
46
47
|
headers: {
|
|
47
48
|
'content-type': endpointResult.dataType || 'application/json',
|
|
49
|
+
...endpointResult.headers,
|
|
48
50
|
},
|
|
49
51
|
statusCode: HttpStatus.Ok,
|
|
50
52
|
body: endpointResult.responseData,
|
|
@@ -53,6 +55,7 @@ export async function handleEndpointRequest({ endpoint, request, response, attac
|
|
|
53
55
|
else {
|
|
54
56
|
return {
|
|
55
57
|
statusCode: HttpStatus.Ok,
|
|
58
|
+
headers: endpointResult.headers,
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rest-vir/run-service",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Run a service defined by @rest-vir/define-service and implemented by @rest-vir/implement-service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rest",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@augment-vir/common": "^31.9.4",
|
|
44
44
|
"@augment-vir/node": "^31.9.4",
|
|
45
45
|
"@fastify/websocket": "^11.0.2",
|
|
46
|
-
"@rest-vir/define-service": "^0.5.
|
|
47
|
-
"@rest-vir/implement-service": "^0.5.
|
|
46
|
+
"@rest-vir/define-service": "^0.5.4",
|
|
47
|
+
"@rest-vir/implement-service": "^0.5.4",
|
|
48
48
|
"cluster-vir": "^0.1.0",
|
|
49
49
|
"date-vir": "^7.2.1",
|
|
50
50
|
"fastify": "^5.2.1",
|