部署Api Laravel和前端Vuejs

问题描述 投票:1回答:0

我正在尝试在托管程序上部署我的应用程序,但不能。 我使用Laravel创建了一个API,并使用VueJS创建了一个前端。 然后,我在服务器文件夹中:

public_html
    index.html
    static
    api
       public
          .htaccess

在我的api文件夹中,我所有的laravel文件都存在我的API中,而在公共文件夹的.htaccess文件中,我有以下代码:

DirectoryIndex public/index.php
<IfModule mod_rewrite.c>

    <IfModule mod_negotiation.c>
      Options -MultiViews
    </IfModule>

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L, R=301]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ public/index.php [L]

    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    Header set Access-Control-Allow-Origin "*"
    Header set Access-Control-Allow-Methods "GET,PUT,POST,DELETE"
    Header set Access-Control-Allow-Headers "Content-Type, Authorization"

</IfModule>

例如,在mydomain.com我从api.mydomain.com/api/some_url获取数据,但是cross-origin错误。

任何人都可以帮助我如何正确设置我的htaccess来与我的api.domain.com/api/some_url我的domain.com吗?

vuejs2 laravel-5.6
© www.soinside.com 2019 - 2024. All rights reserved.