mm_os 2.2.0 → 2.2.1
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/middleware/cors/index.js +6 -7
- package/package.json +1 -1
package/middleware/cors/index.js
CHANGED
|
@@ -14,13 +14,12 @@ module.exports = function(server, config) {
|
|
|
14
14
|
// ctx.set("Access-Control-Allow-Origin", "http://localhost:8080");
|
|
15
15
|
|
|
16
16
|
// 设置所允许的HTTP请求方法OPTIONS,GET,PUT,POST,DELETE
|
|
17
|
-
ctx.set('Access-Control-Allow-Methods', 'PUT,
|
|
18
|
-
|
|
17
|
+
// ctx.set('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,HEAD,OPTIONS');
|
|
19
18
|
|
|
20
19
|
// 字段是必需的。它也是一个逗号分隔的字符串,表明服务器支持的所有头信息字段.
|
|
21
|
-
ctx.set('Access-Control-Allow-Headers',
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// ctx.set('Access-Control-Allow-Headers',
|
|
21
|
+
// 'Content-Type,Content-Length,Authorization,Accept,X-Requested-With,x-auth-token,token,client_id,appid,apikey,user_id,x-forwarded-for,x-real-ip,user-agent,cache-control,pragma,accept-encoding,connection,host'
|
|
22
|
+
// );
|
|
24
23
|
|
|
25
24
|
// 服务器收到请求以后,检查了Origin、Access-Control-Request-Method和Access-Control-Request-Headers字段以后,确认允许跨源请求,就可以做出回应。
|
|
26
25
|
|
|
@@ -29,12 +28,12 @@ module.exports = function(server, config) {
|
|
|
29
28
|
|
|
30
29
|
// 该字段可选。它的值是一个布尔值,表示是否允许发送Cookie。默认情况下,Cookie不包括在CORS请求之中。
|
|
31
30
|
// 当设置成允许请求携带cookie时,需要保证"Access-Control-Allow-Origin"是服务器有的域名,而不能是"*";
|
|
32
|
-
ctx.set("Access-Control-Allow-Credentials", '
|
|
31
|
+
// ctx.set("Access-Control-Allow-Credentials", 'true');
|
|
33
32
|
|
|
34
33
|
// 该字段可选,用来指定本次预检请求的有效期,单位为秒。
|
|
35
34
|
// 当请求方法是PUT或DELETE等特殊方法或者Content-Type字段的类型是application/json时,服务器会提前发送一次请求进行验证
|
|
36
35
|
// 下面的的设置只本次验证的有效时间,即在该时间段内服务端可以不用进行验证
|
|
37
|
-
ctx.set("Access-Control-Max-Age", '3600');
|
|
36
|
+
// ctx.set("Access-Control-Max-Age", '3600');
|
|
38
37
|
/*
|
|
39
38
|
CORS请求时,XMLHttpRequest对象的getResponseHeader()方法只能拿到6个基本字段:
|
|
40
39
|
Cache-Control、
|