More info: I'm on another PC without Herd now, running on artisan serve I get the exact same behavior.
How does Laravel.com add a trailing slash to the api docs link?
Hi,
I have autogenerated api documentation with Doctum
I went through the code and scripts at github/laravel.com to learn how.
I successfully generated the docs, copied them over to /public/docs and can now view them at the following route
Route::get('docs', function () {
return File::get(public_path() . '/docs/index.html');
});
However, none of the css and js files for doctum load unless I have a trailing slash in the url
http://tickets-please.test/docs/
This has to do with doctum using relative paths for everything.
I don't see any such route in laravel.com source but somehow the api docs loads without having index.html in the url and it automatically adds the trailing slash if you leave it off.
I have tried all suggestions I found. The only two that work to add a trailing slash are
- middleware that redirects to a version with the slash
- a rewrite rule in the Nginx site config file
But both of these methods cause a redirect loop because Laravel strips the trailing slash and then the two methods above add it back and it just goes in a loop.
So somehow Laravel.com is doing something to make it work.
2 things laravel.com has
- no route to the api directory
- automatic add the trailing slash but only on the api directory
Any ideas?
Thanks
Please or to participate in this conversation.