Skip to content

Commit 2715671

Browse files
author
浪里行舟
authored
Update a.js
1 parent 5d99fbd commit 2715671

File tree

1 file changed

+18
-4
lines changed
  • 多种跨域方式/8.nginx

1 file changed

+18
-4
lines changed

Diff for: 多种跨域方式/8.nginx/a.js

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
let express = require('express');
2-
let app = express();
3-
app.use(express.static(__dirname));
4-
app.listen(3000);
1+
var http = require('http');
2+
var server = http.createServer();
3+
var qs = require('querystring');
4+
5+
server.on('request', function(req, res) {
6+
var params = qs.parse(req.url.substring(2));
7+
8+
// 向前台写cookie
9+
res.writeHead(200, {
10+
'Set-Cookie': 'l=a123456;Path=/;Domain=www.domain2.com;HttpOnly' // HttpOnly:脚本无法读取
11+
});
12+
13+
res.write(JSON.stringify(params));
14+
res.end();
15+
});
16+
17+
server.listen('8080');
18+
console.log('Server is running at port 8080...');

0 commit comments

Comments
 (0)