我有一个角度应用程序,我需要将其重定向到一个非角度的html页面,所以我想我可以使用$window.location.href将角度应用程序重定向到我的外部网站.这实际上工作正常,但是,我有一个nodejs/express后端,在提供任何内容(甚至静态内容)之前检查身份验证令牌.
这需要在http请求的标头中发送身份验证令牌.现在的问题是:
可以/如何通过更改$window.location.href发送之前的请求添加身份验证令牌?
我正在尝试在运行 nodejs 的弹性 beanstalk 实例上设置基本身份验证,但是,我似乎无法正常工作。我已遵循本指南Amazon EC2 上的 Nginx 服务器,但 http 流量仍然通过 nginx 实例。我认为这是因为 ec2 实例上的 nginx 服务器不是我需要更改文件的服务器virtual.conf。我认为 nginx 服务器完全在另一个实例上,但我似乎找不到它。我认为这是因为当我 ping 我的站点的域名时,它的 IP 是 nginx 服务器的 IP,而不是我的弹性 IP。关于如何配置 nginx 以限制 Elastic beanstalk 上我的网站的 http 和 https 流量有什么想法吗?
我刚刚开始学习节点流,并且正在使用MongoClient(MongoClient游标Doc)。在此文档中,它声明我可以将查询作为文档流来获取。像这样:
var MongoClient = require('mongodb').MongoClient
, assert = require('assert');
// Connection URL
var url = 'mongodb://localhost:27017/myproject';
// Use connect method to connect to the Server
MongoClient.connect(url, function(err, db) {
assert.equal(null, err);
console.log("Connected correctly to server");
var col = db.collection('streams');
// Insert a single document
col.insert([{a:1}, {a:1}, {a:1}], function(err, r) {
assert.equal(null, err);
assert.equal(3, r.result.n);
// Get the results using a find stream
var cursor = col.find({});
cursor.on('data', function(doc) {
console.dir(doc);
});
cursor.once('end', function() {
db.close();
});
});
}); …Run Code Online (Sandbox Code Playgroud) 我目前陷入困境,我需要在HTTPS模式下启动NodeJS服务器并需要读取cert文件,以便在https.createServer(options, app).listen(8443)命令中将它们作为选项.我很难掌握如何将文件读入使用Webpack 2捆绑的TypeScript文件中.例如,
我有2个文件file.crt和file.key.我想在创建https服务器并开始侦听给定端口时读取这些文件.在常规的TS/JS土地上,我可以这样做:
```
import Config from '../env/config';
import Express from '../lib/express';
import * as https from 'https';
import * as fs from 'fs';
let config = new Config();
let app = Express.bootstrap().app;
export default class AppService{
constructor(){
// console.log('blah:', fs.readFileSync('./file.txt'));
}
start(){
let options = {
key: fs.readFileSync('file.key'),
cert: fs.readFileSync('file.crt'),
ca: fs.readFileSync('ca.crt'),
passphrase: 'gulp'
};
https.createServer(options, app).listen(config.port,()=>{
console.log('listening on port::', config.port );
});
}
}Run Code Online (Sandbox Code Playgroud)
但是,当webpack 2构建捆绑包时,这些文件不会被引入,因此当节点启动时它无法找到它们.好吧,我明白了,但我读到原始加载器会为此工作,所以我想我会尝试一下.
这是我的webpack配置文件:
// `CheckerPlugin` is optional. Use it if you …Run Code Online (Sandbox Code Playgroud)node.js ×2
amazon-ec2 ×1
angularjs ×1
http ×1
http-headers ×1
mongodb ×1
nginx ×1
oauth-2.0 ×1
raw-loader ×1
stream ×1
webpack ×1
webpack-2 ×1