Nuxt.js: Nuxt.js "self-signed cretificate error" when backend is on https

Created on 13 Oct 2019  路  2Comments  路  Source: nuxt/nuxt.js

Version

v2.10.0

Reproduction link

https://notapplicable.com

Steps to reproduce

My backend (API endpoints) is running on https://127.0.0.1:8000/api. When that is the case, Nuxt.js is giving the following error:

self signed certificate                                                                                                                                                                                                               18:37:18

  at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
  at TLSSocket.emit (events.js:182:13)
  at TLSSocket.EventEmitter.emit (domain.js:442:20)
  at TLSSocket._finishInit (_tls_wrap.js:631:8)

What's the solution to this? I've seen threads that suggest running Nuxt.js in https mode as well, but all the solutions to do that don't work.

What is expected ?

Nuxt.js should provide a simple way to run nuxt in HTTPS

What is actually happening?

It doesn't

This bug report is available on Nuxt community (#c9900)
bug-report stale

Most helpful comment

Create file

plugins/axios.js

~~~
import https from 'https';

export default function ({ $axios }) {
$axios.defaults.httpsAgent = new https.Agent({ rejectUnauthorized: false });
}
~~~

Update nuxt.config.js

~
plugins: [
'@/plugins/axios',
],
~

This should fix the issue

All 2 comments

Create file

plugins/axios.js

~~~
import https from 'https';

export default function ({ $axios }) {
$axios.defaults.httpsAgent = new https.Agent({ rejectUnauthorized: false });
}
~~~

Update nuxt.config.js

~
plugins: [
'@/plugins/axios',
],
~

This should fix the issue

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikekidder picture mikekidder  路  3Comments

bimohxh picture bimohxh  路  3Comments

vadimsg picture vadimsg  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

VincentLoy picture VincentLoy  路  3Comments