nodejs post 跨域 application/json请求 JFinal seajs

跨域要求url要加http

contentType要求不能加http

用ajax将请求post到Nodejs,Nodejs再把请求转发给JFinal

$.ajax({
        url: '/api/v1/user/reg',
        type: "POST",
        data: {
            "wx": "",
            "name": "",
            "phone": "",
            "code": ""
        },
        dataType: "json",
        success: function(data) {
            console.log(data);
        },
        error: function(error) {
            console.log(error);
        }
    });

var request = require('request-json');
var url = 'http://······.com/';
var client = request.createClient(url);
// var url = 'http://127.0.0.1:8080/';

module.exports = function(app) {
    app.post('/api/v1/*', function(req, res) {
        console.log(req.originalUrl);
        console.log(req.body);
        client.post('car' + req.originalUrl, req.body, function(err, ress, body) {
            res.send(body);
        });
    });
};


你可能感兴趣的:(nodejs,seajs)