Fix staging server deployment #24
Merged
maxime.batista
merged 2 commits from staging/fix
into master
1 year ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'staging/fix'
Deleting a branch is permanent. It CANNOT be undone. Continue?
maxou.dev/IQBall
is currently not serving pages correctly because we directly use the routes as is in our twig views. For example :(in error.html.twig)
The button will redirect to
/home
, which works in our local development servers, but not in our staging server, as there is a base path to place before :https://maxou.dev/staging/fix/public/home
As you can see, to access to the home view on staging server, we must specify a base path before.
the base path is constitued as is :
/<branch>/public
, seeDocumentation/how-to-dev.md
for more information.To fix this, i added into the twig environment, the global variable
basePath
, which is to prepend before each server urls.previous example updated :
This is a valid fix for the issue. In the long term however, you may be interested in exposing functions that create the path instead of relying on the view to "hopefully not forget how to concatenate correctly".
Paths are handled by the router, and it can be used to generate routes given a route name. This may also be interesting to throw an error if the route is defined or to properly encode URL parameters.
$fl = new FilesystemLoader("../src/App/Views");
$twig = new Environment($fl);
$twig->addGlobal("basePath", $basePath);
Because path concatenation cannot always be resumed to a simple string concatenation, exposing a
path(string)
function would hide this base path.header('Content-type: application/json');
echo $response->getJson();
} else {
throw new Exception("API returned a non-json response.");
This change is unrelated, and it is better not to silence such errors.
cc4f60be12
tofffb520dbf
1 year ago2e26056ae9
into master 1 year agoReviewers
2e26056ae9
.