【问题标题】:Create a proxy server changin the referer创建代理服务器更改引用者
【发布时间】:2021-03-19 08:16:00
【问题描述】:

我正在研究 iis,现在我需要将所有请求重定向到 S3,它通过引用授予访问权限。但是在我的代理服务器中没有出现referer,只出现了Host作为代理(Host:proxy.domainhost.com)。

我在 nodejs 中使用请求来做到这一点

const app = require('express')();
const cors = require('cors');
const parser = require('body-parser');
const request = require('request');

app.use(cors());
app.use(parser.urlencoded({ extended: false }))
app.use(parser.json())
app.get('/api/*', function Server(req, res) {
  const url = "https://"+(req.url || '').slice(5)
  req.pipe(request(url)).pipe(res);
});
app.listen(process.env.PORT);

\获取 proxy.domainhost.com/api/s3link/img/0001.png

还有另一种/更好的方法吗?这些请求是由桌面应用程序发出的。我需要将它们全部居中以授予对 s3 的访问权限。

【问题讨论】:

标签: node.js cross-domain


【解决方案1】:
app.get('/api/*', function Server(req, res) {
  const url = "https://"+(req.url || '').slice(5)
  req.pipe(
    request({
      url,
      headers: {
        referer: "targetReferer"
      }
    })
  ).pipe(res);
});
app.listen(process.env.PORT);

感谢您的评论,这就是答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多