3

Running Laravel behind Traefik as reverse proxy, with a Path Prefix (eg /api/ => Laravel).

Laravel is served by Nginx and Php-fpm.

Laravel use Symfony HTTP foundation to generate route URL.

Symfony is not seeing correctly the base path, and generate URL without /api/ prefix.

As a dirty workaround, I fixed it by doing as the 1st line on index.php:

$_SERVER['SCRIPT_NAME'] = '/api/' . $_SERVER['SCRIPT_NAME'];

How can I force the full URL or the base path?

Thomas Decaux
  • 21,738
  • 2
  • 113
  • 124

1 Answers1

0

This was fixed by Symfony team, for Symfony 5.2:

my original issue: https://github.com/symfony/symfony/issues/36809

the PR: https://github.com/symfony/symfony/pull/37734

Thomas Decaux
  • 21,738
  • 2
  • 113
  • 124