michalsn / codeigniter-htmx-demo

This is a demo for CodeIgniter HTMX helper library.
https://michalsn.github.io/codeigniter-htmx/
MIT License
60 stars 13 forks source link

Pressing +- buttons on counter with signed url returns exception #9

Closed dgvirtual closed 1 year ago

dgvirtual commented 1 year ago

Did a fresh install of your project with the signed url's part today. I seem to have configured it right, seeded the db, generated encryption key, but the signed url's do not work. When pressing the + or - buttons on counters I 500 error with this exception:


    "title": "Michalsn\\CodeIgniterSignedUrl\\Exceptions\\SignedUrlException",
    "type": "Michalsn\\CodeIgniterSignedUrl\\Exceptions\\SignedUrlException",
    "code": 500,
    "message": "This URL is not valid.",
    "file": "/tmp/ci-htmx-php8-demo/vendor/michalsn/codeigniter-signed-url/src/Exceptions/SignedUrlException.php",
    "line": 51,
    "trace": [
        {
            "file": "/tmp/ci-htmx-php8-demo/vendor/michalsn/codeigniter-signed-url/src/SignedUrl.php",
            "line": 153,
            "function": "forUrlNotValid",
            "class": "Michalsn\\CodeIgniterSignedUrl\\Exceptions\\SignedUrlException",
            "type": "::"
        },
        {
            "file": "/tmp/ci-htmx-php8-demo/app/ThirdParty/htmx-demo/src/Cells/CounterSigned/CounterSignedCell.php",
            "line": 18,
            "function": "verify",
            "class": "Michalsn\\CodeIgniterSignedUrl\\SignedUrl",
            "type": "->"
        },
        {
            "file": "/tmp/ci-htmx-php8-demo/vendor/codeigniter4/framework/system/View/Cell.php",
            "line": 222,
            "function": "mount",
            "class": "Michalsn\\CodeIgniterHtmxDemo\\Cells\\Counter\\CounterSignedCell",
            "type": "->"
        },
        {
            "file": "/tmp/ci-htmx-php8-demo/vendor/codeigniter4/framework/system/View/Cell.php",
            "line": 99,
            "function": "renderCell",
            "class": "CodeIgniter\\View\\Cell",
            "type": "->"
        },
        {
            "file": "/tmp/ci-htmx-php8-demo/vendor/codeigniter4/framework/system/Common.php",
            "line": 1200,
            "function": "render",
            "class": "CodeIgniter\\View\\Cell",
            "type": "->"
        },
        {
            "file": "/tmp/ci-htmx-php8-demo/app/ThirdParty/htmx-demo/src/Config/Routes.php",
            "line": 52,
            "function": "view_cell"
        },
        {
            "file": "/tmp/ci-htmx-php8-demo/vendor/codeigniter4/framework/system/CodeIgniter.php",
            "line": 883,
            "function": "Michalsn\\CodeIgniterHtmxDemo\\Config\\{closure}",
            "class": "CodeIgniter\\Router\\RouteCollection",
            "type": "::"
        },
        {
            "file": "/tmp/ci-htmx-php8-demo/vendor/codeigniter4/framework/system/CodeIgniter.php",
            "line": 486,
            "function": "startController",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "/tmp/ci-htmx-php8-demo/vendor/codeigniter4/framework/system/CodeIgniter.php",
            "line": 368,
            "function": "handleRequest",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "/tmp/ci-htmx-php8-demo/public/index.php",
            "line": 67,
            "function": "run",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "/tmp/ci-htmx-php8-demo/vendor/codeigniter4/framework/system/Commands/Server/rewrite.php",
            "line": 47,
            "args": [
                "/tmp/ci-htmx-php8-demo/public/index.php"
            ],
            "function": "require_once"
        }
    ]
}``````
michalsn commented 1 year ago

Sorry, I can't reproduce it.

Is anyone else experiencing this problem?

michalsn commented 1 year ago

@dgvirtual Question. By chance, does your baseURL contain a folder, like: http://localhost/project/public/?

dgvirtual commented 1 year ago

@dgvirtual Question. By chance, does your baseURL contain a folder, like: http://localhost/project/public/?

No, it was a regular codeigniter project run by php spark serve command.

However, I did some tinkering today, and the counters started to work once I replaced

public string $indexPage = 'index.php';

with

public string $indexPage = '';

in app/Config/App.php

So, problem solved, but you might want to update the documentation accordingly.

michalsn commented 1 year ago

This sound like a bug in https://github.com/michalsn/codeigniter-signed-url. I will have to look into it soon.

Thanks!