Apache 2 在同一域名上配置 Nuxt 和 Laravel

Apache 2 Configure for Nuxt and Laravel on Same Domain Name

提问人:Paul 提问时间:11/4/2023 更新时间:11/4/2023 访问量:18

问:

我有 Nuxt 应用程序,它依赖于 Laravel 应用程序来获取 API 数据。两者都托管在 example.com

example.com/any-page 拥有所有公共页面

example.com/api/api-data-endpoint 拥有所有数据

我配置apache 2配置的方式是,目前只有主页“/”请求将被代理,其余请求将按原样工作,用于测试目的。

这是我的 conf 文件:

ServerName example.com

ProxyPreserveHost On

    
ProxyPass / http://127.0.0.1:4001/
ProxyPassReverse / http://127.0.0.1:4001/

但是在使用此 conf 之后,所有请求都被代理,我也尝试了以下操作:

ServerName example.com

    ProxyPreserveHost On

    
    ProxyPass /$ http://127.0.0.1:4001/
    ProxyPassReverse /$ http://127.0.0.1:4001/

但是,所有请求仍在代理中。

Laravel Apache Nuxt.js Apache2

评论

0赞 OMi Shah 11/5/2023
在现有代码后添加。这将排除该路径的代理。如果要 exclude eveyr api endpoint,请使用ProxyPass /api/api-data-endpoint !/api*/api/api-data-endpoint

答: 暂无答案