Cross-orgin with Laravel and vuejs

Asked

Viewed 114 times

1

In my dilemma to publish my application I am facing some problems.

I am making the front separate from the back. The frontend is in vuejs and the backend in Laravel (being only an API)

On the server it’s like this:

public_html
      index.html
      static
      api
         app
         database
         config
         ....
         public
            .htaccess

Since index.html and Static are from vuejs and within api are all Laravel files. In my htaccess is like this:

<IfModule mod_rewrite.c>
      RewriteEngine On
      Header set Access-Control-Allow-Origin "*"
      Header set Access-Control-Allow-Headers "Content-Type"
      Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
</IfModule>

When my.com domain requests api.meudominio.com it returns the cross-origin error. How to resolve this?

  • I haven’t touched any other files in the Standard. I just added htacess to the API public. I don’t know if you have any extra settings to make.
  • Checks if the header is being added. Checks if the route is with options released. The browser sends an options before sending the post/put/get/delete request

  • How do I see these things? Is htaccess correct? And it’s right inside the public folder of the project?

  • App/http/Routes.php

  • htaccess stays in the public even if it’s right I don’t know, but I think so

  • I do not have this file in the directory that you reported and in any other part of the project =(

  • Try App Providers Routeserviceprovider / https://laravel.com/docs/5.1/routing

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.