请求 POST - GET React 部署 Heorku

时间:2021-06-29 15:33:11

标签: reactjs react-native heroku deployment axios

请需要您的帮助。 我有一个带有 reactJs 的应用程序,在 localhost 中执行是正确的,但在 Deploy 中使用 Heroku 错误:

enter image description here

我的代码:

const httpsAgent = new https.Agent({ rejectUnauthorized: false });
const session_url = '/oo/rest/executions'
var username = 'myUsername'
var password = 'myPass'
  
axios.post(session_url, sendRequest, {
  Access: false,
  withCredentials: true,
  auth: {
    username: username,
    password: password
  },
  httpsAgent: httpsAgent,
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json"
  }
})

使用 http-proxy-middleware 代理:

const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function(app) {
  app.use(
    '/oo/rest/executions',
    createProxyMiddleware({
      target: 'https://myProxy.com/3000',
      secure: false,
      changeOrigin: true,
    })
  );
};

我不知道如何使请求在 Heroku 中工作。

0 个答案:

没有答案
相关问题