404 API request with pagination in prod mode but works in dev


I use a Laravel API and an Angular service to make my application.
I’m doing a pagination for my array with Angular and I make a HTTP request with this function in my service :

getPagination(page): Observable<any> {
     return this.httpClient.get<any>(environment.apiBaseUrl + 'test/?page=' + page);

When I trigger it I get the data with the pagination but when I want to get another page in prod I get a 404 error because it uses an URL that I don’t even give.

I’m supposed to have this url:


But I get this :


Here is the function in the Laravel API

public function getAll()
        $stuff = MyStuff::orderByDesc('updated_at')->paginate(50); 
        return response()->json($stuff, 200);

The route:

 Route::get('test', [Controller::class, 'getAll']);

When I make a console.log() of the environment.apiBaseUrl in the first call to get the first page I have the right url and same thing for the content:

current_page: 1
first_page_url: "http://prodUrl/back/api/test?page=1"
from: 1
last_page: 3
last_page_url: "http://prodUrl/back/api/test?page=3"
links: (5) [{…}, {…}, {…}, {…}, {…}]
next_page_url: "http://prodUrl/back/api/test?page=2"
path: "http://prodUrl/back/api/test"
per_page: 50
prev_page_url: null
to: 50
total: 146

So why the HTTP request doesn’t use it ?

Source: Angular Questions

Categorized as angular, api, httpclient, laravel Tagged , , ,


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us