这是我第一次在网上部署网站,所以我对某件事感到困惑。向API发出请求。我有自己的express服务器,我向它发送一些数据,它会发送响应。我在客户端有一行代码,我不知道该如何处理:
const res = await axios.post('http://localhost:5000/upload', formdata)
我应该如何修改URL,以便客户端连接到服务器并获取一些信息?(我正在使用heroku部署网站)
发布于 2021-03-16 16:47:49
这非常简单,首先获取部署的heroku应用程序的URL。
默认情况下,Heroku应用程序在其Heroku域中可用,其形式为[name of app].herokuapp.com
。例如,serene-example-4269.herokuapp.com
托管了一个名为serene-example-4269
的应用程序。
因此,对于上面的示例,只需将代码更改为
const res = await axios.post('http://serene-example-4269.herokuapp.com/upload', formdata)
https://stackoverflow.com/questions/66656886
复制相似问题