-
Notifications
You must be signed in to change notification settings - Fork 0
/
cors.js
85 lines (85 loc) · 2.57 KB
/
cors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
module.exports = {
name: "cors",
ns: "express",
title: "CORS",
description: "",
phrases: {
active: "CORS is a node.js package for providing a Connect/Express middleware that can be used to enable CORS with various options"
},
ports: {
input: {
app: {
type: "function",
title: "App",
readonly: "true"
},
express: {
type: "function",
title: "Express",
readonly: "true"
},
origin: {
type: "string",
title: "Origin",
description: "Configures the Access-Control-Allow-Origin CORS header. Expects a string (ex: \"http://example.com\")",
"default": null
},
methods: {
type: "array",
title: "Methods",
description: "Configures the Access-Control-Allow-Methods CORS header. (ex: ['GET', 'PUT', 'POST'])",
"default": null
},
allowedHeaders: {
type: "array",
title: "Allowed Headers",
description: "Configures the Access-Control-Allow-Headers CORS header. (ex: ['Content-Type', 'Authorization]). If not specified, defaults to reflecting the headers specified in the request's Access-Control-Request-Headers header.",
"default": null
},
exposedHeaders: {
type: "array",
title: "Exposed Headers",
description: "Configures the Access-Control-Expose-Headers CORS header. (ex: ['Content-Range', 'X-Content-Range]). If not specified, no custom headers are exposed.",
"default": null
},
credentials: {
type: "boolean",
title: "Credentials",
description: "Configures the Access-Control-Allow-Credentials CORS header.",
"default": false
},
maxAge: {
type: "number",
title: "Max Age",
description: "Configures the Access-Control-Allow-Max-Age CORS header. Set to an integer to pass the header, otherwise it is omitted.",
"default": null
}
},
output: {}
},
dependencies: {
npm: {
cors: require('cors')
}
},
fn: function cors(input, $, output, state, done, cb, on, cors) {
var r = function() {
$.app.cors(cors({
origin: $.origin || true,
methods: $.methods || undefined,
allowedHeaders: $.allowedHeaders || undefined,
exposedHeaders: $.exposedHeaders || undefined,
credentials: $.credentials || undefined,
maxAge: $.maxAge || undefined
}), function corsCallback() {
cb({});
});
}.call(this);
return {
output: output,
state: state,
on: on,
return: r
};
}
}