Redirecting to :80 port after authorization

iplague
Member | 7
+
0
-

Hello!

Have next problem:
after authorization redirecting :80/?_fid=q8b9 to this, what doest it mean?

Last edited by iplague (2023-05-02 18:57)

materix
Backer | 83
+
+3
-

The _fid parameter is used for flash messages. Flash messages are commonly used to display success or error messages to users after they complete an action, like submitting a form or logging in.

You can just ignore it, and leave it as it is.

iplague
Member | 7
+
0
-

Ок, 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
+
0
-

@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.

iplague
Member | 7
+
0
-

Unfortunately i don't know how do to this.

I use web hosting, https protocol.
` $this->redirect(‘Sign:in’);` redirect to :80
` $this->redirectUrl(‘Sign:in’);` works normaly

iplague
Member | 7
+
-2
-

just use redirectUrl now

Marek Bartoš
Nette Blogger | 1261
+
+2
-

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
+
0
-

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 ?

mskocik
Member | 61
+
0
-

How do you have router configured in the neon file? Can you paste all your config files (no need for local.neon)?

Seems like your app is fallbacking to SimpleRouter, ie. to query string routing

Marek Bartoš
Nette Blogger | 1261
+
0
-

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 action out

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
+
0
-

Add RouteList – ensure that you use Nette\Application\Routers\RouteList and not Nette\Routing\RouteList. The Application RouteList would fail without the required metadata.

iplague
Member | 7
+
0
-

My project:

Git

Now everything works.

iplague
Member | 7
+
-4
-

In file:
/vendor/nette/http/src/Http/RequestFactory.php

97–99 line:
elseif (isset($_SERVER[‘SERVER_PORT’])) {
// $url->setPort((int) $_SERVER[‘SERVER_PORT’]); // – comment
$url->setPort((int) ‘443’); // – add this one
}