Base path feature malformed CLI output and lacking documentation #1402
Labels
bug
troubleshooting
Tickets in which an issue was happening which was not obvious to solve and required support
Milestone
How Shlink is set-up
Summary
The base path feature seems bugged. Short URLs return 404 errors, the API endpoints return 404 errors, and the CLI output does not look correct (though unfortunately this last issue seems cosmetic).
Current behavior
The
DEFAULT_DOMAIN
is set toexample.com
and theBASE_PATH
is set toshlink
ingenerated-config.php
, but theShort URL
field output bybin/cli short-url:list
ishttps://example.comshlink/shlink/ZJxAM
instead of the expectedhttps://example.com/shlink/ZJxAM
. When trying to use the short URLhttps://example.com/shlink/ZJxAM
, Shlink shows the generic 404 page and logs aregular_404
error in the database.Edit 1: When
BASE_PATH
is set to/s
, theShort URL
outputbecomes
https://example.com/s/s/ZJxAM
. Changing the nginxconfiguration to match does not solve the issue: Shlink still shows the
generic 404 page and logs a
regular_404
error in the database (withthe
visited_url
correctly logged ashttps://example.com/s/s/ZJxAM
, suggesting the CLI output is wrong). I’ve tried settingBASE_PATH
tos
,/s
,/s/
, and leaving it empty and puttingexample.com/s
in theDEFAULT_DOMAIN
, all without luck.Edit 2: Now things are looking weird. Even when I configureBASE_PATH
to be empty (theShort URL
becomeshttps://example.com/ZJxAM
) and use nginx to rewrite the path before passing it on to openswoole so Shlink seeshttps://example.com/s/ZJxAM
as justhttps://example.com/ZJxAM
, I’m getting 404 errors.Edit 3: Deleted
data/cache/fastroute_cached_routes.php
; solved the empty base path 404 problem in Edit 2. I will let nginx continue “lying” to Shlink for now as a workaround.Edit 4: Deleting
data/cache/fastroute_cached_routes.php
was the missing magic sauce. It seems like I need to manually do this step every time I test a newBASE_PATH
even thoughvendor/bin/shlink-installer set-option
claims it has “properly updated” the configuration. This would be a really great note to add to the troubleshooting documentation, along with an example of how to setBASE_PATH
so people don’t need to guess whether to usepath
(which doesn’t work) or/path
(works) or/path/
(haven’t tested)!Now I have confirmed that setting
BASE_PATH
to/shlink
works, redirectinghttps://example.com/shlink/ZJxAM
as expected. However,bin/cli short-url:list
continues to return malformedShort URL
s likehttps://example.com/shlink/shlink/ZJxAM
. At least it’s confirmed the issue is cosmetic.Expected behavior
When the
DEFAULT_DOMAIN
is set toexample.com
and theBASE_PATH
is set toshlink
ingenerated-config.php
, theShort URL
field output bybin/cli short-url:list
should behttps://example.com/shlink/ZJxAM
, nothttps://example.comshlink/shlink/ZJxAM
. When trying to use the short URLhttps://example.com/shlink/ZJxAM
, Shlink redirects according to the configuration (301) and logs the visit normally in the database.How to reproduce
Install Shlink from the openswoole dist release on an Ubuntu 20.04 LTS Minimal Google Compute Engine instance with nginx and mariadb, configuring the default domain as
example.com
and the base path asshlink
.nginx configuration
The text was updated successfully, but these errors were encountered: