Vite.js, specifically in conjunction with Vue.js, experiences an issue with undesired page reloads, but this

Encountering an unusual issue with Vite.js specifically on Samsung Internet while using the development server...

The problem at hand involves a continuous automatic page reload every 3 seconds, without any intentional intervals being set or written. This unexpected behavior seems to occur at the browser level.

These unwanted reloads are disrupting normal functioning and need to be resolved promptly.

Any insights into the root cause of this puzzling occurrence?

Answer ā„–1

It appears that the Samsung Internet browser has restrictions on insecure websockets as discussed here.

To work around this issue, you can enable HTTPS in Vite by setting server.https to create a secure Websocket connection:

// vite.config.js
import { defineConfig } from 'vite'

export default defineConfig({
  ā‹®
  server: {
    https: true,
  }
})

This solution has been confirmed with Vite version 2.7.13 and Samsung Internet version 16.0.6.23

Answer ā„–2

Revised answer:

Upon further investigation into the issue, I have identified some potential solutions.

It appears that Samsung Internet (similar to Chrome) does not support unsecure websocket (ws) connections to localhost, only secure wss connections. To resolve this, you may need to configure a TLS certificate for your local web/websocket server. On the other hand, Firefox should be able to connect without any issues.

Another possible cause for the error could be port congestion, where another application running on your system is also using port 3000. In such cases, either terminating the conflicting process or changing the port configuration can help alleviate the issue.

You can verify if the changes work by testing the code with the following modification:

// Original line
new WebSocket(`${socketProtocol}://${socketHost}`, 'vite-hmr')

// Replace it with the specific URL and port that corresponds to your app
new WebSocket("ws://localhost:3000")

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

Changing the `$location.path` updates the URL without triggering a redirect

When I try to redirect to another page by clicking a button or a link, the URL changes but the redirection doesn't happen. I have to manually refresh the page with the new URL. I'm not sure if the issue lies in the module or the controller. loca ...

Limiting the table width in TinyMCE

Currently, I am utilizing TinyMCE within a Vue application. I've set up TinyMCE with the table_grid: false configuration, causing a dialog to appear when a table is created. This dialog allows users to specify rows, columns, width, and more. Within t ...

Using CSS properties as false values within React applications

Can you provide guidance on using conditional styles with conditional operators? What would be the ideal code example? Is it possible to use non-CSS values? margin: isOpen ? '10px' : undefined margin: isOpen ? '10px' : 'initial&a ...

What steps can be taken to identify the two highest numbers in an array, one being positive and the other

Seeking the optimal solution to resolve this issue Issue: Develop a function called ArrayChallenge (Javascript) that takes a single argument "arr" representing an array of numbers. The function should return the string true if there exist two numbers in t ...

Whenever a user tries to retrieve a page using ajax and then proceeds to submit the form associated with that page, they encounter

In my addQuestions.php file, I have four options available - single, multiple, matrix, and true false type questions with values 1-4 assigned to each respectively. To dynamically load the appropriate question type based on user selection, I am using AJAX w ...

The AudioPlayerStatus module in Discord JS is a powerful tool for managing

Could you explain why this code snippet: client.player.once(AudioPlayerStatus.Idle, () => { console.log(client.playlist); next.run(message, args, client); client.playlist.shift(); return; }); is b ...

I am unable to retrieve all the selected checkbox values from the pug template in Express

If you are following the Express MDN tutorial here, you might have encountered an issue with pulling in checkbox values from Pug. In the tutorial, req.body.genre is expected to return an array of selected values from a form. The code snippet for this func ...

"Enhance your online shopping experience with a React.js popup modal for

In the midst of developing a shopping cart, I find myself facing a challenge in making the modal pop up when clicking on the shopping cart icon. The semantic-ui documentation for modals has not provided clear instructions on achieving this functionality, s ...

Error: The function SomeFunction is not recognized as a valid function (Mongoose library)

Help needed! I'm encountering an error stating "TypeError: User.getUserByUsername is not a function at Strategy._verify (.../routes/users.js:65:10) var User = require('../models/user'); passport.use(new LocalStrategy( function(username, ...

Is there a way to conceal the loading screen until the website has completely loaded?

I've been working on my personal portfolio/website and encountered a bug that I can't seem to fix on my own. The issue is with the logo (aa) and text under it showing even after the content page has fully loaded, taking around 3 seconds to hide. ...

Event delegation will be ineffective when the target element is nested within another element

After receiving a recommendation from my colleagues on Stackoverflow (mplungjan, Michel), I implemented the event delegation pattern for a comment list. It has been working well and I am quite excited about this approach. However, I have encountered an iss ...

Using React Hooks and useRef to Retrieve the clientHeight of Dynamically Rendered Images

I'm currently in the process of creating a dynamic image grid and need to determine the exact height of each image in pixels so I can adjust the layout accordingly. However, I've encountered an issue with accessing ref.current.clientHeight as it ...

Reorganize code in JavaScript and TypeScript files using VSCode

Is there a way to efficiently organize the code within a .js / .ts file using Vscode? Specifically, when working inside a Class, my goal is to have static variables at the top, followed by variables, then methods, and so on automatically. I did some resea ...

What's causing this javascript to malfunction on the browser?

I encountered a problem with the code in my .js file. Here is a snippet of the code: $.extend(KhanUtil, { // This function takes a number and returns its sign customSign: function(num){ num = parseFloat(num) if (num>=0){return 1} ...

Building a stylish table using Material UI in ReactJS

I've been working on creating a dashboard using the Material UI minimized table. You can check out the documentation here: Material UI Tables However, I've encountered an issue that has me stuck for the past 5 hours. While I was able to successf ...

Fetching real-time Twitter search feeds through dynamic AJAX requests

Previously, I successfully used JSON to retrieve hash tag feeds from Twitter and Facebook. However, currently the feeds are not updating dynamically, indicating a need for Ajax implementation. Unfortunately, my lack of knowledge in Ajax is hindering this ...

Using VueJs to dynamically adjust the width of an element based on another element

Iā€™m currently developing a Trivia app that features an <h1> element which dynamically changes every 10 seconds. My goal is to align the width of a radio button group component (b-form-group from Bootstrap-Vue components) with the width of the <h ...

Which is the better option for opening a link in a button: using onclick or href?

What is the most effective way to open a link using a button? <button type="button" onclick="location='permalink.php'">Permalink</button> <button type="button" href="index.php">Permalink</button> ...

Tips for activating multiple buttons at once

Currently, I am facing a challenge with managing three buttons that are dynamically generated within a div using v-for in Vue.js. My goal is to set an active class on the clicked button while removing the active class from the previously selected button. A ...

Develop a game timer using CreateJS

Looking for advice on the most effective method to create a timer clock using Createjs. I've attempted to reference HTML elements with DOMElement in the past, but encountered difficulties. Essentially, I need to display a timer within a container so p ...