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.

Capacitor mode not working with an https devServer

See original GitHub issue

Describe the bug Capacitor doesn’t seem to be recognised when running in dev mode with an https devServer.

Codepen/jsFiddle/Codesandbox (required) –> capacitor mode, won’t help

To Reproduce Steps to reproduce the behavior:

  1. Install a new Quasar 2 project
  2. Change https: true in the devServer section in quasar.conf.js
  3. Add to App.vue the following code:
import { Platform } from 'quasar'
console.log(Platform.is)

Expected behavior When running capacitor with quasar dev -m capacitor -T android, the value of Platform.is is:

{
  android: true
  capacitor: true
  chrome: true
  mobile: true
  name: 'chrome'
  nativeMobile: true
  nativeMobileWrapper: 'capacitor'
  platform: 'android'
  version: '83.0.4103.106'
  versionNumber: 83
  webkit: true
}

But when turning in devServer.https to true in quasar.conf.js, Platform.is then is:

{
  android: true
  chrome: true
  mobile: true
  name: 'chrome'
  platform: 'android'
  version: '83.0.4103.106'
  versionNumber: 83
  webkit: true
}

It basically behaves like capacitor native has not been loaded at all. I wish I could use the http devServer mode, but unfortunately I have to use navigator.mediadevices that can only be accessed in a secure context…

Platform (please complete the following information): OS: MacOS Node: v13.11.0 NPM: 6.9.0 Yarn: 1.22.4 Browsers: N/A iOS: N/A Android: 10 Electron: N/A

Additional context @quasar/app: 2.0.0 @capacitor/core: 2.2.0

It may worth to notice the following error in the ADB logs:

I/X509Util: Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

and a recurrent:

E/chromium: [ERROR:ssl_client_socket_impl.cc(959)] handshake failed; returned -1, SSL error code 1, net_error -202

Many, many thanks in advance!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mwahlhuettercommented, May 4, 2021

Im currently facing the same problem, and just checking window.Capacitor does not solve the underlying problem of Capacitor not running in native mode when using a dev server with https. I can not test notifications on Android in my dev environment because capacitor just loads the web plugins and not the native plugin I need for push notifications.

If I use the check when deciding to either use the node package for firebase messaging or the native capacitor plugin I get the error Uncaught (in promise) PushNotifications does not have web implementation

@nklayman if you could look into this again it would be greatly appreciated!

Edit: Found the solution for my problem in the following issue. I just enclosed the code in an

if (BuildConfig.DEBUG) {
    ...
}

statement and added it to the onCreate method in the MainActivity class.

https://github.com/ionic-team/capacitor/issues/3707#issuecomment-718965440

1reaction
nklaymancommented, Jul 2, 2020

A bug report should probably be created for capacitor as window.Capacitor isn’t available when it should be. I’ll do this when I get the chance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Capacitor core plugins break when setting devServer to 'https'
I'm working on an Android app using Quasar and Capacitor. ... I needed to change the dev server to use https so I...
Read more >
Live Reload | Capacitor Documentation
Use Live Reload to easily debug the web and native portions of an app on a device or simulator.
Read more >
How to run Vue.js dev serve with https? - Stack Overflow
Going off of NearHuscarl answer, using Vue Cli with vue 3.0.0, key and cert had to be placed at the devServer level (not...
Read more >
Live Reload | Ionic Documentation
One option that can boost productivity when building Ionic apps is Live Reload (or live-reload). When active, Live Reload will reload the browser...
Read more >
Handling process.env - Quasar Framework
differentiating runtime procedure depending on Quasar Mode ... The env variables from the terminal that are available in ... MY_API : 'https://prod.
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