• Extensions
  • Progressive Web App (PWA) and Push Notifications

Trying to do a 302 redirect and get this:

405
POST https://akr-developers.com/api/pwa/push

{
  "errors": [
    {
      "status": "405",
      "code": "method_not_allowed",
      "detail": "Flarum\\Http\\Exception\\MethodNotAllowedException: GET in /var/www/akr-developers.com/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php:60\nStack trace:\n#0 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\DispatchRoute->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#1 /var/www/akr-developers.com/vendor/fof/sentry/src/Middleware/HandleErrorsWithSentry.php(28): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#2 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): FoF\\Sentry\\Middleware\\HandleErrorsWithSentry->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#3 /var/www/akr-developers.com/vendor/flarum/core/src/Http/Middleware/SetLocale.php(50): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#4 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\SetLocale->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#5 /var/www/akr-developers.com/vendor/flarum/core/src/Http/Middleware/CheckCsrfToken.php(37): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#6 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\CheckCsrfToken->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#7 /var/www/akr-developers.com/vendor/flarum/core/src/Http/Middleware/AuthenticateWithHeader.php(55): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#8 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\AuthenticateWithHeader->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#9 /var/www/akr-developers.com/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(32): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#10 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\AuthenticateWithSession->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#11 /var/www/akr-developers.com/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(51): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#12 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\RememberFromCookie->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#13 /var/www/akr-developers.com/vendor/flarum/core/src/Http/Middleware/StartSession.php(61): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#14 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\StartSession->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#15 /var/www/akr-developers.com/vendor/flarum/core/src/Api/Middleware/FakeHttpMethods.php(29): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#16 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Api\\Middleware\\FakeHttpMethods->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#17 /var/www/akr-developers.com/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(28): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#18 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\ParseJsonBody->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#19 /var/www/akr-developers.com/vendor/flarum/core/src/Http/Middleware/HandleErrors.php(57): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#20 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\\Http\\Middleware\\HandleErrors->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#21 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(84): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#22 /var/www/akr-developers.com/vendor/middlewares/request-handler/src/RequestHandler.php(84): Laminas\\Stratigility\\MiddlewarePipe->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#23 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Middlewares\\RequestHandler->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#24 /var/www/akr-developers.com/vendor/middlewares/base-path-router/src/BasePathRouter.php(97): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#25 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Middlewares\\BasePathRouter->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#26 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Middleware/OriginalMessages.php(42): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#27 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Laminas\\Stratigility\\Middleware\\OriginalMessages->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#28 /var/www/akr-developers.com/vendor/middlewares/base-path/src/BasePath.php(53): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#29 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/Next.php(61): Middlewares\\BasePath->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\Next))\n#30 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(84): Laminas\\Stratigility\\Next->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#31 /var/www/akr-developers.com/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(73): Laminas\\Stratigility\\MiddlewarePipe->process(Object(Laminas\\Diactoros\\ServerRequest), Object(Laminas\\Stratigility\\EmptyPipelineHandler))\n#32 /var/www/akr-developers.com/vendor/laminas/laminas-httphandlerrunner/src/RequestHandlerRunner.php(96): Laminas\\Stratigility\\MiddlewarePipe->handle(Object(Laminas\\Diactoros\\ServerRequest))\n#33 /var/www/akr-developers.com/vendor/flarum/core/src/Http/Server.php(42): Laminas\\HttpHandlerRunner\\RequestHandlerRunner->run()\n#34 /var/www/akr-developers.com/public/index.php(26): Flarum\\Http\\Server->listen()\n#35 {main}"
    }
  ]
}

    wloot Hmm you're not the first to report this, but I'm unsure why a GET request is being called on /api/pwa/push in the first place? What are you redirecting to where?

      askvortsov I did return ngx.redirect(ngx.var.request_uri) it will redirect to same page so i can do refresh

      Could you try and look through your network log in the dev tools console in Chrome, and try to figure out at what point a get request is being made to that endpoint?

        Error caught by sentry:

        TypeError: Cannot read property 'unsubscribe' of null
          at ? (webpack://@askvortsov/flarum-pwa/./src/forum/addPushNotifications.js:59:24)
        5 days later

        Seems that I'm not the only one who's got this issue while enabling the extension...

        PDOException: SQLSTATE[42000]: Syntax error or access violation: 1142 REFERENCES command denied to user 'forum'@'localhost' for table 'forum.users'

        askvortsov
        Reviewed phpMyAdmin I found that you have to grant privilege for REFERENCES to your MySQL user Manually 🤔
        If something went wrong still appears, simply delete push_subscription table and it should be working fine 😉

        A new problem encountered: the web push can't function while minishlink/web-push is required 🤔
        How can I check the status of the extension?

        When I turn on the extension for the first time, an error with the database pops up. I don't know how to solve it.
        PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes in ...

          iPurpl3x Nope, neither are necessary! It uses the Push API, which is a part of the service worker system being introduced into browsers.

          6 days later

          Dear @askvortsov ,

          Something from this extension is making my flarum forum to break in old browsers.
          I can confirm this after testing with the following browsers;

          1. Microsoft Edge v44.18362.449.0
          2. Google Chrome v58.0.3029.83

          When the extension is active it breaks on page load for everyone and renders a pure HTML which says;
          "Something went wrong while trying to load the full version of this site. Try hard-refreshing this page to fix the error. " then All Discussions appear under in pure HTML with no CSS.

          Meanwhile, when the extension is disabled, my flarum forum loads just fine.

          Edit:
          To satisfy my curiosity and further confirm that its not only on my setup, I tested it on Connectome

            Operator How much market share does that version of Google Chrome and older actually take up? I mean Chrome is on version 83+ and nothing older than 83.0.4103 is supported by Google, further Google has released several critical security patches since version 58.

            As for Edge that's a slightly larger issue because of the fact that "regular" edge is still a pretty big thing at the moment (although Edge Chromium is quickly taking over)

              tankerkiller125 I totally agree with you on this. I am just concerned because Flarum's Discuss loads well in the said browser and my flarum forum also loads well when i disable the extension.

              askvortsov Don't stress yourself too much on this, as @tankerkiller125 said, if these browser vendors do not support them, who are we to do so.

              This ext worked really well on my forum, but not sure if its a bug, when i already uploaded an image for logo, once i want to change the logo, it wont let me change the logo. I have removed all existing logos and uploading the new logo, but the image will be uploaded as the previous images. Tried to cleard the cache but the logo still wont change, i mean the 1st uploaded logo not replaced by the new one

                • [deleted]

                snfansclub Yes, I experienced this also. In the end, I landed up having to clear the cache (including browser cache), renaming all uploaded files (and also deleting them from the assets folder). Finally got it working, but seeing as nobody else mentioned it, I thought it was just me 🙂

                When i press Like:
                [2020-06-30 07:10:46] production.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function getStatusCode() on null in /usr/share/nginx/akr-developers.com/vendor/askvortsov/flarum-pwa/src/Listener/SendPushNotifications.php:112