-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues on cloudflare #35
Comments
I'm facing the same issue. Did you find a workaround @Knaackee? |
@stefanmaric not really. I had different things to do and hoped it's getting fixed in the meantime. Does the problem still exist in the latest version? |
Bummer 😢
Unfortunately, it's still broken. |
For the sake of completeness, here's a minimal reproduction: https://stackblitz.com/edit/withastro-astro-cz8era Hard to actually test without deploying, but to confirm the issue:
The reproduction follows closely the Astro guide (https://vite-pwa-org.netlify.app/frameworks/astro.html) and copies some of the code from the Astro simple example (https://stackblitz.com/edit/vite-pwa-astro-pu12pn?file=package.json,astro.config.mjs) but adds the Cloudflare adapter via Hope this helps! |
can you add I have no idea about the I'm going to check the reproduction on my local. |
It seems we need to review the Astro integration, the file is generated in the server folder, that file shouldn't be on the sw.js precaching manifest: |
Once I'll check changes in Astro next weekend. |
So, |
I guess there's none because it is being server-rendered on the fly. 🤔 |
uhmm, you need navigate fallback there, at least 1 html page to use it for the offline handler |
so, |
we can use https://stackblitz.com/edit/withastro-astro-covosb?file=astro.config.mjs,src%2Fpages%2Findex.astro https://docs.astro.build/en/guides/server-side-rendering/#configure-server-or-hybrid |
@userquin I confirmed that switching to It makes total sense that if you're going to pre-cache the whole site/app, of course you need all paths to be listed in the pre-cache manifest. Astro knows all the paths (or at least path patterns, when using path params) that are server-rendered. Would it be possible to somehow emit these to be passed to workbox's pre-cache manifest? 🤔 |
Any SSR page or api calls must be excluded from sw interception via You can use the runtime caching (NetworkFirst only) to cache ssr pages or api calls: check this issue vite-pwa/sveltekit#65 |
Getting a similar error as well using https://antares-ajj.pages.dev/
AstroPWA({
mode: import.meta.env.PROD ? "production" : "development",
base: "/",
scope: "/",
includeAssets: ["favicon.svg"],
registerType: "autoUpdate",
injectRegister: false,
manifest: {
name: "Astro PWA",
short_name: "Astro PWA",
theme_color: "#ffffff",
},
pwaAssets: {
config: true,
},
workbox: {
navigateFallback: "/",
globPatterns: ["**/*.{css,js,html,svg,png,ico,txt}"],
navigateFallbackDenylist: [/^\/keystatic/, /^\/api/],
skipWaiting: true,
maximumFileSizeToCacheInBytes: 3 * 1024 * 1024,
},
devOptions: {
enabled: false,
navigateFallbackAllowlist: [/^\//],
},
experimental: {
directoryAndTrailingSlashHandler: true,
},
}), Service worker is trying to precache the file
if (!self.define) {
let e,
i = {};
const r = (r, n) => (
(r = new URL(r + ".js", n).href),
i[r] ||
new Promise((i) => {
if ("document" in self) {
const e = document.createElement("script");
(e.src = r), (e.onload = i), document.head.appendChild(e);
} else (e = r), importScripts(r), i();
}).then(() => {
let e = i[r];
if (!e) throw new Error(`Module ${r} didn’t register its module`);
return e;
})
);
self.define = (n, o) => {
const s =
e ||
("document" in self ? document.currentScript.src : "") ||
location.href;
if (i[s]) return;
let a = {};
const l = (e) => r(e, s),
d = {
module: {
uri: s,
},
exports: a,
require: l,
};
i[s] = Promise.all(n.map((e) => d[e] || l(e))).then((e) => (o(...e), a));
};
}
define(["./workbox-7cfec069"], function (e) {
"use strict";
self.skipWaiting(),
e.precacheAndRoute(
[
{
url: "_astro/_slug_.Cde6an2G.css",
revision: null,
},
{
url: "_astro/client.DWoRQa5Q.js",
revision: null,
},
{
url: "_astro/cover.BdKIT5TF_853z.svg",
revision: null,
},
{
url: "_astro/cover.BdKIT5TF.svg",
revision: null,
},
{
url: "_astro/cover.CGTzvcyc_1r0W35.svg",
revision: null,
},
{
url: "_astro/cover.CGTzvcyc.svg",
revision: null,
},
{
url: "_astro/cover.CpMCnsuV_Z1Fjueq.svg",
revision: null,
},
{
url: "_astro/cover.CpMCnsuV.svg",
revision: null,
},
{
url: "_astro/cover.Cw7VWPk8.png",
revision: null,
},
{
url: "_astro/cover.D1iqTLTc_2bkcxW.svg",
revision: null,
},
{
url: "_astro/cover.D1iqTLTc.svg",
revision: null,
},
{
url: "_astro/Hero.astro_astro_type_script_index_0_lang.r2T_yKjW.js",
revision: null,
},
{
url: "_astro/Highlights.astro_astro_type_script_index_0_lang.BaCW6DQl.js",
revision: null,
},
{
url: "_astro/hoisted.B_gY8znj.js",
revision: null,
},
{
url: "_astro/hoisted.Bd2Fo4VE.js",
revision: null,
},
{
url: "_astro/index.ClJOJl_Y.js",
revision: null,
},
{
url: "_astro/index.ZORhgBxb.js",
revision: null,
},
{
url: "_astro/keystatic-page.DeFKh_T3.js",
revision: null,
},
{
url: "_astro/page.BIe0mclZ.js",
revision: null,
},
{
url: "_astro/ScrollTrigger.BS49OFpx.js",
revision: null,
},
{
url: "_astro/Testimonials.astro_astro_type_script_index_0_lang.CL6AE6rR.js",
revision: null,
},
{
url: "_astro/workbox-window.prod.es5.DFjpnwFp.js",
revision: null,
},
{
url: "_worker.js/index.js",
revision: "d8b0d90558f335be0d6e7bab4c83a57c",
},
{
url: "404",
revision: "d03080907a49fa1d36507b268164a35f",
},
{
url: "apple-splash-landscape-dark-2048x1536.png",
revision: "b7931e4f19e992daf4b7c5dd3d9d7040",
},
{
url: "apple-splash-landscape-light-2048x1536.png",
revision: "905b7bcabd0edb29f8c1e8201ead83a4",
},
{
url: "apple-splash-portrait-dark-1536x2048.png",
revision: "06aeb87629d33fe6a35a21e3970ed2ca",
},
{
url: "apple-splash-portrait-light-1536x2048.png",
revision: "25e638e6242323c525c95eb1566647e8",
},
{
url: "apple-touch-icon-180x180.png",
revision: "504617f70e1429d8169a7dbe7e29e964",
},
{
url: "assets/js/squircle.js",
revision: "55b5c47e7ea184a69b82773f4875e9ed",
},
{
url: "blog/index.html",
revision: "db8e0fc1ed6d96bb6bca380c27a1e40d",
},
{
url: "chisiamo/index.html",
revision: "36feb2e8593188e11d27bab0ff9c47d1",
},
{
url: "contatti/index.html",
revision: "814dee91966fffb2226b41428fa1fa9c",
},
{
url: "convenzioni/index.html",
revision: "d6891b29e74da445d3094e59c3f9d32d",
},
{
url: "favicon.ico",
revision: "21591a66f8436363b21958a4efc5f6ef",
},
{
url: "favicon.svg",
revision: "be70d577c3675201316f69bb7d638c93",
},
{
url: "feedback/index.html",
revision: "b6ba36868f325e2601e677c3cf642c7e",
},
{
url: "index.html",
revision: "d44ad5271d824a11000c21667810a77a",
},
{
url: "listino/index.html",
revision: "be62499a2ecdf8e8f4ea994c14bd2aa7",
},
{
url: "maskable-icon-512x512.png",
revision: "78e61de871b7db96e06b70f96a744022",
},
{
url: "post/alimenti-amici-e-nemici-dei-tuoi-denti/index.html",
revision: "602a9b980917c37a576431f3d9c683f9",
},
{
url: "post/come-prevenire-la-carie-nei-bambini-consigli-pratici-per-i-genitori/index.html",
revision: "8b46beabf4e013c996381505b16a7f69",
},
{
url: "post/ortodonzia-invisibile-vantaggi-e-considerazioni/index.html",
revision: "749df4d4489b6963601e30ed0aae0aec",
},
{
url: "post/tecnologie-avanzate-in-odontoiatria-cosa-c-e-di-nuovo-nel-2024/index.html",
revision: "f5bfddf416f13149527fe3df840ae4f0",
},
{
url: "prenota/index.html",
revision: "fbabe5782e1ab0065d6569086e445e0c",
},
{
url: "pwa-192x192.png",
revision: "fec60c8f8d7d8c69a275d222e2b2b08b",
},
{
url: "pwa-512x512.png",
revision: "4b8b04f0380ead96b81704526bb16684",
},
{
url: "pwa-64x64.png",
revision: "9f9e27aa926a829306c6ebc62b1203af",
},
{
url: "robots.txt",
revision: "ee674a6951f4d321ff7f9bd1e1027d1a",
},
{
url: "servizi/index.html",
revision: "2eb9c352e7fe22fee9db0e8a2d20592f",
},
{
url: "terms/index.html",
revision: "d212bcc9bc304d624f260be187db48e4",
},
{
revision: "db8e0fc1ed6d96bb6bca380c27a1e40d",
url: "blog",
},
{
revision: "36feb2e8593188e11d27bab0ff9c47d1",
url: "chisiamo",
},
{
revision: "814dee91966fffb2226b41428fa1fa9c",
url: "contatti",
},
{
revision: "d6891b29e74da445d3094e59c3f9d32d",
url: "convenzioni",
},
{
revision: "b6ba36868f325e2601e677c3cf642c7e",
url: "feedback",
},
{
revision: "d44ad5271d824a11000c21667810a77a",
url: "/",
},
{
revision: "be62499a2ecdf8e8f4ea994c14bd2aa7",
url: "listino",
},
{
revision: "602a9b980917c37a576431f3d9c683f9",
url: "post/alimenti-amici-e-nemici-dei-tuoi-denti",
},
{
revision: "8b46beabf4e013c996381505b16a7f69",
url: "post/come-prevenire-la-carie-nei-bambini-consigli-pratici-per-i-genitori",
},
{
revision: "749df4d4489b6963601e30ed0aae0aec",
url: "post/ortodonzia-invisibile-vantaggi-e-considerazioni",
},
{
revision: "f5bfddf416f13149527fe3df840ae4f0",
url: "post/tecnologie-avanzate-in-odontoiatria-cosa-c-e-di-nuovo-nel-2024",
},
{
revision: "fbabe5782e1ab0065d6569086e445e0c",
url: "prenota",
},
{
revision: "2eb9c352e7fe22fee9db0e8a2d20592f",
url: "servizi",
},
{
revision: "d212bcc9bc304d624f260be187db48e4",
url: "terms",
},
{
url: "favicon.svg",
revision: "be70d577c3675201316f69bb7d638c93",
},
{
url: "manifest.webmanifest",
revision: "2e71caf2df5898a0638a1e9e1a803b8e",
},
],
{
directoryIndex: "index.html",
},
),
e.cleanupOutdatedCaches(),
e.registerRoute(
new e.NavigationRoute(e.createHandlerBoundToURL("/"), {
denylist: [/^\/keystatic/, /^\/api/],
}),
);
}); but that file is never uploaded, even if it's created with the build command,
In fact going to https://antares-ajj.pages.dev/_worker.js/index.js result in a 404 On cloudflare I see this https://developers.cloudflare.com/pages/functions/advanced-mode/ not sure if there is something I have to activate. On the functions tab of the build log I see this
Are the files under Thanks |
is the Anyway, you can add |
When I build the package I see it in the relative folder, but I don't see it when on the uploaded files on cloudflare
Ok, that's not something that this package use correct? Using
Fix the problem Thanks |
workbox-build will traverse the dist folder (any integration: Vite, Remix, SvelteKit, Nuxt...), if the adapter or Astro generating content in the client or server build that's not included in the final distro, we should collect any input and add proper exclusions for that inputs. For example, SvelteKit generates a dist folder with the client (client folder) SSG pages (prerendered folder ) and server (server folder): pwa kit integration will include only SvelteKit generates always that structure, independent from the adapter, the adapter will use the SvelteKit output folder. If Astro or any Astro adapter using same folder it will be hard to fix the problem, we will need in Astro PWA integration the adapter to update the workbox/injectManifest options properly. |
Ok thanks |
Using official astro vite-pwa integration with cloudflare ssr adapter, only this pattern for globIgnores works for me
|
At first, thanks for the great work!
I am playing around with an empty astro project, but I have issues using
@vite-pwa/astro
.Everything works locally, but online I get the following error (registerSW.js).
Any Idea?
The text was updated successfully, but these errors were encountered: