Max*_*ain 5 javascript node.js express parse-platform
我正在使用 parse.com 来托管我的应用程序。我已经构建了一个简单的 api 来反馈 json。网址很简单,如下所示:http://websitename.parseapp.com/api/new/1/10。现在,我的 api 是公开可见的,但我想限制访问,以便只有来自相同域名的页面才能访问它。我怎样才能用 express.js 实现这一点?
这是我所拥有的示例代码:
var express = require('express');
var app = express();
// Global app configuration section
app.set('views', 'cloud/views');  // Specify the folder to find templates
app.set('view engine', 'ejs');    // Set the template engine
app.use(express.bodyParser());    // Middleware for reading request body
// This is an example of hooking up a request handler with a specific request
// path and HTTP verb using the Express routing API.
app.get('/api/:page/:from/:to', function(req, res) {
  res.render('hello', { message: 'Congrats, you just set up your app!' });
});
// This line is required to make Express respond to http requests.
app.listen();
| 归档时间: | 
 | 
| 查看次数: | 3217 次 | 
| 最近记录: |