部署Api Laravel和前端Vuejs

时间:2018-03-20 18:34:47

标签: vuejs2 laravel-5.6

我试图在hostinger上部署我的应用程序,但我不能。我已经使用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,以便将domain.comapi.domain.com/api/some_url通信?

0 个答案:

没有答案