How to access a project route (URL) written in Laravel from another project (URL) that does not use Laravel?

Asked

Viewed 235 times

0

Let’s say I have myApp1.com and myApp2.com, and that only the second project is written in Laravel.

My question is:

Taking into account that myApp2.com has login authentication, it would be possible to create a link in myApp1.com that would direct to a route on myApp2.com ?

//myApp1.com
<a href="http://myApp2.com/fazerAlgo/">Faça algo em myApp2.com</a>

//myApp2.com
Route::get('/fazerAlgo', 'outConttroler@fazerendoAlgo')

1 answer

0


Completely,

Would look like this:

myApp1.com

<a href="http://myApp2.com/do-something/">Faça algo em myApp2.com</a>

myApp2.com
Route

 Route::get('do-something', 'DoSomethingController@do_something');

Controller

public function do_something()
{
    echo "Hello World";
}

I just tested it worked perfect here.
NOTE: Of course your authentication session would not be passed to the myApp2.com

I hope I’ve helped.

  • ok... if you have tested then this is beautiful. But it doesn’t seem strange? What is the use then of authentication filters? How does the Laravel allow this? Then we could create a form on another server to access controllers within myApp2.com?

  • Hence you should use token in the forms, to avoid this kind of unwanted access.

  • See here https://laravel.com/docs/5.2/routing#form-method-spoofing

Browser other questions tagged

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