作为回应,我已提交此表格:
this.handleSubmitOrder(event) }>name="client"
className="input is-dark is-large"
type="text"
placeholder="Client name"
required
//value={this.state.formClient.client}
onChange={this.handleOrderFormChange}
/>
name="email"
className="input is-dark is-large"
type="text"
placeholder="Client email"
required
//value={this.state.formClient.email}
onChange={this.handleOrderFormChange}
/>
type="submit"
className="button is-dark is-large is-fullwidth"
value="Submit"
/>
这是
handleSubmitOrder()
,处理
POST
请求:
handleSubmitOrder(event) {
const {userId} = this.props
const data = {
client: this.state.formClient.client,
email: this.state.formClient.email,
};
var headers = {
'Content-Type': 'application/json',
//'Access-Control-Allow-Origin': true,
Authorization: `Bearer ${window.localStorage.authToken}`
}
const url = `${process.env.REACT_APP_WEB_SERVICE_URL}/orders/${userId}`;
axios.post(url, data, {headers: headers})
.then((res) => {
console.log(data);
})
.catch((err) => {
});
};
我用
nginx
作为代理服务器(nginx.conf):
location /orders {
proxy_pass http://web:5000;
proxy_redirect default;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
在我的烧瓶服务器上,我有自己的观点,特别声明
岗位
仅方法:
@orders_bp.route('/orders/', methods=['POST'])
def orders(user_id):
# business logic
return jsonify(response_object), 200
这个端点已经到达,逻辑在
/orders
正在成功处理。
但当我提交表格时
404
浏览器出错,而且,令我困惑的是,一个GET请求:
"GET /orders?client=Ozorio&email=ozo%40gmail.com&phone=118888888&select=pick HTTP/1.0" 404 -
如果有帮助的话,我还在这里声明了url:
应用jsx:
(
formType={'Orders'}
isAuthenticated={this.state.isAuthenticated}
/>
)} />
在navbar,我要的网址是:
{props.isAuthenticated &&
Orders
}
注:我是经认证的。
这里可能有什么问题?非常感谢您的帮助。