Redirecting to :80 port after authorization
- iplague
- Member | 7
Ок, now I don't use flash messages, but redirecting to port **:80 ** continues
It happend after redirect function
protected function startup(): void
{
parent::startup();
if (!$this->getUser()->isLoggedIn()) {
$this->redirect('Sign:in');
}
}
Last edited by iplague (2023-05-02 19:54)
- nightfish
- Member | 517
@iplague Does your site by any chance run behind a HTTP proxy? If so, you need to configure Nette so that it is able to correctly detect website's base URL.
- Marek Bartoš
- Nette Blogger | 1261
That just shouldn't work at all. redirectUrl() expects actual url, not Nette mapping.
Webhostings usually have IP addresses they use documented. Just look for them or ask for them. Then place them in config, as described in documentation https://doc.nette.org/…onfiguration#…
- iplague
- Member | 7
router:
$router = new RouteList;
$router
->addRoute('', 'Home:home')
->addRoute('about', 'Home:about')
->addRoute('contacts', 'Home:contacts')
->addRoute('parliament', 'Pages:parliament')
->addRoute('passport', 'Pages:passport')
->addRoute('news', 'News:index')
->addRoute('sign/out')
->addRoute('sign/in')
->addRoute('sign/up');
.htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# prevents files starting with dot to be viewed by browser
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule /\.|^\.(?!well-known/) - [F]
# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|mjs|ico|gif|jpg|jpeg|png|webp|svg|css|rar|zip|7z|tar\.gz|map|eot|ttf|otf|woff|woff2)$ index.php [L]
</IfModule>
redirect functions, for example:
` $this->redirect(‘Sign:in’);`
redirect me to:
:80/sign/out?action=in&presenter=Sign
Please, tell me, I need to edit common.neon config file to add http: proxy ?
- Marek Bartoš
- Nette Blogger | 1261
addRoute('sign/out')
does not seem right, you have a route with
no information how it should be handled. You need to always define at least
presenter, otherwise Nette does not handle the route automatically.
Either as a variable in mask:
addRoute('<presenter>/<action>')
- Matches any url in
foo/bar
format - e.g. in
sign/out
url,sign
is used as a presenter,out
is matched as a action
Or as a constant in metadata:
addRoute('sign/out', 'Sign:out')
- Matches only
sign/out
- Always maps request to
sign
presenter and actionout
Or with alternative syntax for constants:
addRoute('sign/out', [
'presenter' => 'Sign',
'action' => 'out',
])
If fixing your router does not help, add http > proxy
config
to any neon file which is added in app/Bootstrap.php
via
$configurator->addConfig()
. But general idea is that
common.neon
is for config that is same for all application
instances (e.g. for registering services) while local.neon
is
customized for each server (e.g. database connection settings and http proxy
because they are different)
Last edited by Marek Bartoš (2023-05-04 12:27)
- Marek Bartoš
- Nette Blogger | 1261
Add RouteList – ensure that you use
Nette\Application\Routers\RouteList
and not
Nette\Routing\RouteList
. The Application RouteList would fail
without the required metadata.