What could be causing the never-ending page reloads on a PWA Vue application?

I'm currently working on turning my Vue app into a PWA using the Vite-PWA-plugin (this plugin)

However, I've encountered an issue where the page keeps reloading repeatedly when served from cache, especially when utilizing the Oauth2 protocol for authorization with the oidc-client.js library.

Some observations:

  1. Opening the PWA offline avoids this problem.
  2. Clearing the cache storage allows the page to load normally.

Below is my vite.config.ts file:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa'
const path = require('path')

export default defineConfig({
  plugins: [
    vue(),
    VitePWA({
      includeManifestIcons: true,
      manifest: {
        icons: [
          {
            src: 'icons/android-launchericon-512-512.png',
            sizes: '512x512',
          },
          {
            src: 'icons/android-launchericon-192-192.png',
            sizes: '192x192',
          },
        ],
      },
    }),
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      functions: path.resolve(__dirname, './src/components/functions'),
    },
  },
  server: {
    port: 8000,
  },
})

My manifest:

{
  "name": "my-app",
  "short_name": "my-app",
  "start_url": "/",
  "display": "standalone",
  "background_color": "#ffffff",
  "lang": "en",
  "scope": "/",
  "icons": [
    { "src": "icons/android-launchericon-512-512.png", "sizes": "512x512" },
    { "src": "icons/android-launchericon-192-192.png", "sizes": "192x192" }
  ]
}

Answer №1

After transitioning from CRA to Vite, I encountered a similar issue. By deleting the excess files added by CRA for PWA support, my problem was resolved.

It seems that the problem stemmed from workbox not being able to locate sw.js, possibly due to the conflicting presence of leftover CRA files.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using rxjs for exponential backoff strategy

Exploring the Angular 7 documentation, I came across a practical example showcasing the usage of rxjs Observables to implement an exponential backoff strategy for an AJAX request: import { pipe, range, timer, zip } from 'rxjs'; import { ajax } f ...

What is preventing me from renaming a file in PHP when passed through jQuery?

Hello to all users! I've encountered an issue where I can't seem to change the file name in PHP that is being passed from jQuery: Here is the JavaScript code where I pass the file to the PHP handler: var url = '/temp.php'; var xhr = ...

Is the new mui LoadingButton not available in the latest version?

According to the material UI documentation found at here, you are supposed to import LoadingButton from '@material-ui/lab/LoadingButton'; However, I am unable to locate this folder within mui/lab and the import statement is resulting in an erro ...

VueJS - also remember to include line breaks at the start and end of a textarea element

Working with axios in a VueJS component to submit a textarea that is bound with v-model. <textarea placeholder="Enter text here" v-model="body"></textarea> The submission works correctly (without the dot): Example text . After a line break ...

Problem with custom anchor component in React that needs to perform an action before being clicked

React Component (Custom Anchor) import React from 'react'; class Anchor extends React.Component { onClick = (event) => { // ----------------------------- // send Google Analytics request ...

The contenteditable div's selectAll feature doesn't function properly when it gains focus

I'm working with divs in a table structure and here's an example: <div contenteditable="true" onfocus="document.execCommand('selectAll',false,null)">Something</div> Clicking on a div to focus works perfectly, selectin ...

Angularjs regex filter: applying regular expressions to filter data

I've created a regex pattern to match URLs like this: /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/ Now, I need to incorporate this regex into a filter that will specifically extra ...

Retrieval of components from JSON array of objects

I have a JSON array containing objects stored on the server. How can I access the first object to print its contents? The data is in the following format: [ { "eventId": "8577", "datasetId": "34", "nodeId": "8076", "typeId": "4", "type": ...

Getting the desired value from a CreatableSelect in React can be achieved by following these steps:

I have a form that includes a React library component called React Select. I'm struggling to retrieve the target value of this input field. Here's my code snippet: # CreatableSelect tag <CreatableSelect className={Astyle.selectInput} i ...

Exploring nested objects and arrays with Plunker - extracting their values

I have retrieved two arrays, each containing nested objects, from API endpoints. One array (preview) consists solely of numbers. For example: [{ obj1:[1, 2], obj2:[3, 4] }] To obtain strings associated with IDs, I made another call to a different en ...

FastAPI template does not support Vue.js in its current form

Looking to incorporate Vue.js using a CDN in an application served by fastApi. I successfully created a prototype without fast API, only utilizing the CDN Vue in index.html and app.js. The combination worked seamlessly as the count increased when the butt ...

Dealing with asynchronous data using mermaid-js in Angular

Currently, I am engrossed in a project that involves retrieving data from the DB asynchronously and utilizing it to create a sequence diagram using mermaid.js' markdown syntax. Nevertheless, an issue has cropped up where the sequence diagram gets rend ...

When implementing v-model on a v-dialog component, it causes the element within an array to

There is an array of apps with links, and a Dialog component that has v-model="dialog" to close it. However, after adding v-model to the v-dialog, the functionality of the apps is affected. The current app is passed as a prop to Dialog, but it always sends ...

AngularJS $location Redirect Error: Property 'path' Undefined

I'm struggling with an issue in my AngularJS code where I am trying to change the URL without reloading the page when a submit button is clicked. However, I keep getting a TypeError: Cannot read property 'path' of undefined in the console. ...

Issues with displaying images in Fancybox

I've integrated FancyBox into my website, but I'm experiencing a minor issue. While the FancyBox works perfectly in Dreamweaver, it seems to malfunction in various browsers. As someone who is not well-versed in programming, I'm struggling t ...

Converting a string to a date in JavaScript

Is there a way to convert a string like "20150415" into a date with the format "2015, April, 15th"? I've come across multiple examples, but they all involve splitting with "-" or "/", which doesn't work for my case. Below is my current code snip ...

Tips for sending multiple values to a jquery dialog box

I am seeking assistance with passing multiple values to a jQuery dialog box and displaying them in a table within the dialog box... The HTML content is being rendered in the dialog box through an AJAX call. Here is my AJAX call: $.get(url, function (dat ...

Having difficulty grasping the concept of toggleClass and jQuery selectors

I am struggling to understand the getLiveSearchUsers function in my JS file. Could someone please help me? I don't quite grasp what selector[0] is and what toggleClass is doing here. $.post("includes/handlers/ajax_search.php", {query:value, userLogge ...

unable to respond when clicking an angularjs link

I'm facing an issue where I can't get a link to respond to click events in AngularJS. When I click on the anchor link, nothing happens. Here is a snippet of the AngularJS script: <script data-require="<a href="/cdn-cgi/l/email-protection" ...

Receiving an error in TypeScript stating that the property or data does not exist on the type for Vue props

I've recently integrated TypeScript into my Vue project, and now I'm encountering an error every time I try to access a value in props or data: 37:46 Property 'activity' does not exist on type '{ props: { activity: { type: ObjectC ...