user67223
user67223

Reputation: 33

How to fix redirects frontend url and api url in laravel?

I need help making a redirect. I am working on a project that the front-end reactjs and the back-end laravel are in different domains. The system has file registration and they are stored in the spaces of the digital ocean. When the system returns the file url, the returned url is concatenating the front-end base url with the file url in spaces, example:

http://localhost:8000/http://localhost:3000

In web routes:

Route::any('/', function () {
    header('Location: ' . env('APP_FRONTEND_URL'));
    die;
});

How to fix redirects?

Upvotes: 1

Views: 2524

Answers (1)

5637800
5637800

Reputation: 687

You can use following code to redirect to your frontend url.

return redirect()->away(env('APP_FRONTEND_URL'));

Also check official documentation redirect

Upvotes: 2

Related Questions