Skip to content

requestWithoutTrailingSlash on CompiledRouteCollection cause base URL "/" to not work if laravel public folder is linked through api symlink in html folder #56682

@marzoli

Description

@marzoli

Laravel Version

12.24

PHP Version

8.4.8

Database Driver & Version

PostgreSQL

Description

In the main html folder i have a symbolic link "api" linked to "public" laravel folder. This because in the main html folder i have the compiled angular UI.
I have a route based on the base API URL (apiPrefix = ''): Route::get('/', ...)
If I use route:cache, the Request URL in the CompiledRouteCollection is cleaned of / via requestWithoutTrailingSlash. This causes the API to return: The GET method is not supported for route /.
Without route:cache, it works.

Steps To Reproduce

Steps To Reproduce

Run php artisan route:cache

Open a web browser locally with a URL that includes a subpath, using one of the following methods:

http://localhost/bug-report/public/

or

Create a symlink named api pointing to the public Laravel folder, then open http://localhost/api/ (my case)
The important thing is that there is a subpath in the URL.

I created this repository https://github.com/marzoli/bug-report with your instructions.

I also changed Readme.md with instructions to reproduce

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions