Laravel Spa(Laravel+ Vuejs+ Sanctum)部署在子域中返回错误的API

发布于 2025-02-09 12:03:11 字数 711 浏览 1 评论 0原文

几天以来,我就有这个问题。

我正在开发一个使用Sanctum作为身份验证者的Vuejs/Laravel应用程序。 Laravel主要具有API遗传角色,我开始部署它。在本地,一切看起来都不错,API和Auth正在工作。

在部署时,由于我的应用程序呈粘在子域中(laravelapp.maindomain,带有域/laravelapp的文件夹路径),所以当我尝试访问任何页面(vue-router)而不是域/laravelapp/login时,我获得域/login in ,即使页面本身看起来还不错。

如果我尝试重新加载重定向页面(域/页面),我有一个404。此外,由于每个API都指向域/API/链接,而不是域/LaravelApp/api/link,因此从AUTH开始,一切都会损坏。

我已经尝试修改.ENV文件,routeserviceProvider,.htaccess(但我对此一无所知)。

我还试图将子域文档的root设置为域/laravelapp(这是我已经完成的第一件事),但不仅它不起作用,如果我尝试在屏幕域子域的根上打印,它会返回域。现在,这已成为一个真正的问题,谢谢您的任何帮助。

编辑:我发现了一些东西。在主要域中,有一个Joomla应用程序。 API路由包含Joomla重定向(例如,有一个插件OH,网站自动更改语言,附加 /EN /IT /DE给定所选语言)。因此,就我而言,API是域/index.php/en/子域。我再次尝试使用文档root,没有结果并与.htaccess一起玩,但没有成功。

I have this problem since several days.

I'm developing a Vuejs/laravel app, using Sanctum as an authenticator. where laravel mainly have the api gestion role, and I've started to deploying it. On Local, everything looks fine, api and auth are working.

On deploy, since my app is binded to be in a subdomain (laravelapp.maindomain with folder path of domain/laravelapp), when i try to access any page (vue-router) instead of domain/laravelapp/login i get domain/login, even if the page itself is looking fine.

If i try to reload the redirected page (domain/page) i have a 404. Also, since every API is pointing to domain/api/link instead of domain/laravelapp/api/link, everything is broken starting with auth.

I've tried modifying .env file, RouteServiceProvider, .htaccess(but i have no knowledge about that).

I also tried to set the subdomain Document Root to domain/laravelapp (it's the first thing i've done), but not only it dosn't work, if I try to print on screen subdomain's root, it returns domain. It's becoming a real issue right now, thank you for any help.

EDIT: I've discovered something. in the main domain there is a Joomla application. The api route contains the Joomla redirect (like, there is a plugin oh the site that changes language automatically, appending /en /it /de given the chosen language). So, in my case, the api is domain/index.php/en/subdomain. I tried again being more specific with document root, with no results, and playing around with .htaccess, but with no success.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文