Packaging fails when "Offline browsing" enabled in WordPress
jessuppi opened this issue · comments
What's your suggestion for improvement for our docs?
I don't think this is a bug, it's probably happening for a reason. I have seen dozens of Issues about PWABuilder failing to package the Android app with various 500 errors or APK related errors e.g.
Error: Error generating Android package.
Status code: 500
Error: Internal Server Error
Details: Error generating app package:
invalid json response body at ..... reason: Unexpected token < in JSON at position 0
stack: FetchError: invalid json response body at ..... reason: Unexpected token < in JSON at position 0
Anyway, our community at SlickStack recently discovered this happens on WordPress sites when the "Offline browsing" feature is enabled under Settings >> Reading.
After disabling that feature, the Android package downloads with no more problems.
Ref: https://slickstack.io/forum/topic/cant-generate-pwa-package-from-pwabuilder-many-errors
I just wanted to let you guys know, for future Googlers etc.
Do you have an implementation or a solution in mind?
No response
Have you considered any alternatives?
No response
Hey @jessuppi do you have an example web manifest that this wordpress plugin generates? It sounds like it is not valid JSON from the error, but this would help us confirm.
For the semi-official PWA plugin released by WordPress.org, the manifest URL is here:
/wp-json/wp/v2/web-app-manifest
I ran a few tests, with the Offline browsing option both enabled and disabled but the JSON output appeared the same. It could be a coincidence during my tests, maybe previously the output was NOT the same, but unlikely:
{"name":"Example Site","start_url":"https:\/\/example.com\/","display":"minimal-ui","dir":"ltr","short_name":"Example","lang":"en-US","background_color":"#fff","theme_color":"#fff","description":"My website is about cats","icons":[{"purpose":"any","src":"https:\/\/example.com\/wp-content\/uploads\/sites\/4\/2023\/12\/cropped-logo-512-192x192.png","sizes":"192x192","type":"image\/png"},{"purpose":"any","src":"https:\/\/example.com\/wp-content\/uploads\/sites\/4\/2023\/12\/cropped-logo-512.png","sizes":"512x512","type":"image\/png"}]}
It validates fine on JSONLint too.
The JSON output appears minified, but I think that is from Cloudflare. In any regard, the minification didn't seem to hurt anything because on subsequent attempts, PWA Builder packaging worked fine.
By the way, it might be related, I saw the problem on a WordPress Multisite installation. I haven't found any documentation or similar experiences to mine, so just wanted to share. The HTTP headers also appear to be the same both with Offline browsing enabled and disabled.
Ahhhh, you mentioned Cloudflare, yeah this is probably minified from them. Another weird thing I noticed is those icon URLs don't seem to load correctly in my browser. Thanks for sharing this info, I am going to close this issue for now as you mentioned its working for you now, but again, thanks for the info!