Use setBasePath() on prod (if you call app from subdir)

If you release your slim4 application to a production site where you do not have setup a virtual host,
be sure to set the base path with app->setBasePath().

I have a REACT application on www.tangosweden.se
Below this I have my index.php located in subdir /app/slim4/public.

In this case I use app->setBasePath(‘/app/slim4/public’)

Then the application find my abbreviated routes that I define in routes.php.

Just a side note: Make sure that the public/ directory is your DocumentRoot of the website. Then you don’t need to set a base path.