[英]How can I make the npm start IP address sync with php artisan serve to use backend functionality on mobile device?
I have a React.js frontend project and Laravel backend project separated.我有一个 React.js 前端项目和 Laravel 后端项目分开。 I can access my frontend project via the local host address provided upon running npm start
so I can see the frontend on a physical device of what I'm working on.我可以通过运行npm start
提供的本地主机地址访问我的前端项目,这样我就可以在我正在处理的物理设备上看到前端。
However - When I try to login (backend functionality) on my physical device, it won't allow me to.但是 - 当我尝试在我的物理设备上登录(后端功能)时,它不允许我这样做。 php artisan serve
's running on my backend project and I can successfully login on the browser without any issues so my login system isn't the issue. php artisan serve
正在我的后端项目上运行,我可以成功登录浏览器而没有任何问题,所以我的登录系统不是问题。
I guess my question is - how can I make it so that my physical device knows that php artisan serve
's running so I can access my web app with the localhost address given to me provided by npm start
?我想我的问题是 - 我怎样才能让我的物理设备知道php artisan serve
正在运行,以便我可以使用npm start
提供给我的本地主机地址访问我的网络应用程序?
In other words - how can I make 127.0.0.1:8000
( php artisan serve
) sync up with 192.168.2.165:3000
( npm start
)?换句话说 - 我怎样才能让127.0.0.1:8000
( php artisan serve
) 与192.168.2.165:3000
( npm start
) 同步?
I think you want to have your app request proxied to your backend server.我认为您希望将您的应用程序请求代理到您的后端服务器。 take a look at this from Create-react-app doc : https://create-react-app.dev/docs/proxying-api-requests-in-development/从 Create-react-app doc 看看这个: https : //create-react-app.dev/docs/proxying-api-requests-in-development/
Based on your description you should add this line to your package.json for your react app :根据您的描述,您应该将此行添加到您的 react 应用程序的 package.json 中:
"proxy": "http://192.168.2.165:8000"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.