Lua在ROBLOX中的HTTP请求给我返回403,但在其他地方测试时可以正常运行

local httpService = game:GetService("HttpService");
local s = httpService:GetAsync("https://rbxapi.herokuapp.com/api/Users/1");
print(s);

这是一个简单的GET请求,发送给我的代理服务器,但它一直给我返回403错误。

HTTP 403 (HTTP/1.1 403 Forbidden)

当在其他网站(如API tester)上测试URL时,它完全正常并且通过了测试。

代理服务器托管在Heroku上,这是服务器的代码:

const _express = require("express"),
      _proxy = require("express-http-proxy"),
      _fs = require("fs");
      _body_parser = require("body-parser")
var client = _express();

var port = process.env.PORT || 5000;

client.use("/api", _proxy("https://api.roblox.com", {
    proxyReqPathResolver: function(req){
        return require('url').parse(req.url).path;
    },
}));

client.listen(port, (err) =>{
    if(err){
        console.log(`Error: ${err}`);
        return;
    } else {
        console.log(`Server is now listenin' on port ${port}!`);
    }
})

点赞
用户9987644
用户9987644

解决了,ROBLOX知道它来自游戏服务器,因此拒绝它。

2018-06-25 09:38:12