部署构建React项目后,PHP响应为空

部署我的react项目的build文件夹后,我尝试登录,但是我注意到该会话为空。我的项目的输出大部分是错误的,因为每个页面都需要会话。我尝试调试,发现我的PHP文件没有数据响应。

请问我的代码有什么问题。 在这里。

handleclick = event =>  {
event.preventDefault();

if (this.validateForm()) {
  let loginform = document.getElementById('login');
  let formData = new FormData(loginform);
  formData.append('username',this.state.username)
  formData.append('password',this.state.password)
  formData.append('company',this.state.company)
  formData.append('division',this.state.division)

  axios({
  method: 'post',url: this.getHostname()+'/new_vehicle_management/src/components/php/login.php',data: formData,config: 
  {
    //headers:{'Content-Type':'multipart/form-data'
    headers: {
      "access-control-allow-origin": '*',"access-Control-Allow-Credentials": 'true',"access-Control-Allow-Methods":'GET,POST,PATCH,PUT,DELETE,OPTIONS',"Content-Type": "multipart/form-data",accept: "application/json"
  }}
  })
  .then(function (response) {
          if (response.data === "failed") {
           alert("Connection Failed.")
          }else if (response.data === "No Company") {
            alert("Company does not exist.")
           }else if (response.data === "No Division") {
            alert("Division does not exist.")
           }else if (response.data === "No User") {
            alert("username does not exist.")
           }else if (response.data === "Not Match") {
            alert("username and Password does not match.")
           }else if(response.data === "No Record"){
            alert("Invalid Credentials.");
           }
           else{
            alert("Login Successfully")
            localStorage.setItem('data',JSON.stringify(response.data))
            localStorage.setItem('user_id',JSON.stringify(response.data.user_id))
            localStorage.setItem('user',JSON.stringify(response.data.user_full_name))
            localStorage.setItem('div_id',JSON.stringify(response.data.div_id))
            localStorage.setItem('comp_id',JSON.stringify(response.data.comp_id))
            window.location = "/menu"
           }
        })
        .catch(function (response) {
            //handle error
            console.log(response)
        });
}         
}
fishin8 回答:部署构建React项目后,PHP响应为空

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3169427.html

大家都在问