question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Https dev server locks mobile Safari in infinite redirect loop

See original GitHub issue

Describe the bug

Using https causes infinite redirecting behaviour in iOS Safari

Reproduction

  1. Set the server to use https
  2. Visit the dev site using iOS Safari and one of the network IPs
  3. Confirm the “Visit unsecure web site”
  4. Site keeps re-loading rapidly, switching between site URL and certificate warning URL

System Info

  • vite version: 2.0.4
  • Operating System: MacOS 11.2.1, iOS 14.4
  • Node version: 14.0.0
  • Package manager (npm/yarn/pnpm) and version: Yarn 1.22.5

Logs (Optional if provided reproduction)

  1. Run yarn dev using https

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
Kashuabcommented, Jun 17, 2021

Here’s a workaround (Mac specific instructions):

  1. Install mkcert
  2. Generate a cert $ mkcert localhost <your local IP, i.e. 192.168.1.51>
  3. Point vite to the generated key and cert .pems:
{
  // ... your other config ...
  server: {
    https: {
      key: './key.pem',
      cert: './cert.pem',
    },
    host: '0.0.0.0',
  }
}
  1. Locate mkcert’s rootCA.pem file by running the following command:

$ mkcert -CAROOT

  1. Copy the outputted path, open finder, go to Go > Go to folder, paste in the path and hit “Go”
  2. Unlock your iDevice
  3. Airdrop the rootCA.pem file to your iDevice
  4. Open your settings app, at the top you should see an option to install the downloaded profile
  5. When done, go to Settings > General > About > Certificate Trust Settings (at the bottom) > Toggle full trust for the mkcert root certificate

You should now be able to view your local app by entering your local IP in safari, i.e. https://192.168.1.51:4000

2reactions
sapphi-redcommented, May 30, 2022

I confirmed this still happens. I tested with 2.0.4 and 2.3.0 and 2.9.9 and 3.0.0-alpha.7.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Safari refresh loop with webpack-dev-server in https mode
So I am using webpack-dev-server with standard HMR configuration (but with https: true ) and the browser keeps refreshing even if I don't ......
Read more >
Too many redirects Safari iOS - Apple Community
Anytime I'm using mobile data (AT&T) and try going to ... running the web site have an HTML or JavaScript redirect bug (an...
Read more >
Too many redirect on login page after move the site from http ...
I run gitlab-ce 8.16.3, installed as omnibus package on ubuntu server 14.04. The server run behind a firewall in our private network, ...
Read more >
How to Fix “Too Many Redirects” WordPress Error - DreamHost
The “too many redirects” WordPress error can occur when your site gets stuck in a redirection loop due to an issue with your...
Read more >
How to Fix Error Too Many Redirects Issue in WordPress
However, this error doesn't tell you what's causing the conflict and forcing the redirect loop in WordPress. This is how the error looks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found