From a7e1dfc2531cd8da6112194c17c0d591a22a50af Mon Sep 17 00:00:00 2001 From: Sam Blowes Date: Mon, 16 Mar 2020 16:04:53 +0000 Subject: [PATCH 1/2] fix(https): https does not work on localhost https://cmty.app/nuxt/axios-module/issues/c346 --- lib/module.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/module.js b/lib/module.js index c183297d..2e4337ad 100755 --- a/lib/module.js +++ b/lib/module.js @@ -89,7 +89,7 @@ function axiosModule (_moduleOptions) { // Convert http:// to https:// if https option is on if (options.https === true) { - const https = s => s.includes('//localhost:') ? s : s.replace('http://', 'https://') + const https = s => s.replace('http://', 'https://') options.baseURL = https(options.baseURL) options.browserBaseURL = https(options.browserBaseURL) } From 4917dd18065729ac5d429054607a42b8190ff1af Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Fri, 27 Mar 2020 12:23:46 +0100 Subject: [PATCH 2/2] test: fix baseURL always honor https --- test/axios.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/axios.test.js b/test/axios.test.js index efc11299..606c4e85 100644 --- a/test/axios.test.js +++ b/test/axios.test.js @@ -29,7 +29,8 @@ const testSuite = () => { expect(addTemplate).toBeDefined() const call = addTemplate.mock.calls.find(args => args[0].src.includes('plugin.js')) const options = call[0].options - expect(options.baseURL.toString()).toBe('http://localhost:3000/test_api') + const proto = options.https ? 'https' : 'http' + expect(options.baseURL.toString()).toBe(`${proto}://localhost:3000/test_api`) expect(options.browserBaseURL.toString()).toBe('/test_api') })