Permalink
Browse files

feat: https option (#57)

  • Loading branch information...
pi0 committed Feb 4, 2018
1 parent 4d31c1e commit 9ecb547f51a0542268b290c787f8c1934558124b
Showing with 16 additions and 1 deletion.
  1. +7 −0 README.md
  2. +9 −1 lib/module.js
@@ -63,6 +63,7 @@ If you are coming from an older release please be sure to read [Migration Guide]
* [Prefix, Host and Port](#prefix-host-and-port)
* [baseURL](#baseurl)
* [browserBaseURL](#browserbaseurl)
* [https](#https)
* [progress](#progress)
* [proxy](#proxy)
* [retry](#retry)
@@ -306,6 +307,12 @@ Base URL which is used and prepended to make requests in client side.

Environment variable `API_URL_BROWSER` can be used to **override** `browserBaseURL`.

### `https`

* Default: `false`

If set to `true`, `http://` in both `baseURL` and `browserBaseURL` will be changed into `https://`.

### `progress`

* Default: `true`
@@ -41,7 +41,8 @@ module.exports = function nuxtAxios (_moduleOptions) {
proxyHeaders: true,
proxyHeadersIgnore: ['accept', 'host'],
proxy: false,
retry: false
retry: false,
https: false
},
moduleOptions
)
@@ -70,6 +71,13 @@ module.exports = function nuxtAxios (_moduleOptions) {
options.retry = {}
}

// Convert http:// to https:// if https option is on
if (options.https === true) {
const https = s => s.replace('http://', 'https://')
options.baseURL = https(options.baseURL)
options.browserBaseURL = https(options.browserBaseURL)
}

// Register plugin
this.addPlugin({
src: path.resolve(__dirname, 'plugin.template.js'),

0 comments on commit 9ecb547

Please sign in to comment.