Skip to content
Permalink
Browse files
fix(module): always set protocol to https when https: true is set (
  • Loading branch information
blowsie committed Mar 27, 2020
1 parent b6f88ae commit 6f82570b163c4d4635321601f05d0c4641a00f19
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
@@ -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://')

This comment has been minimized.

Copy link
@TarekRaafat

TarekRaafat Mar 31, 2020

It doesn't work for me during development, because it issues secured requests on the localhost unsecured dev server.
On production as well doesn't work with unstable SSL service providers.

This comment has been minimized.

Copy link
@pi0

pi0 Mar 31, 2020

Member

Hi. So if you don't want SSL at all why setting https: true is needed?

Sorry for the inconveniences BTW. I tried to explain in #344 why we need to deprecate this option. I highly recommend using different baseURL based on prod/dev and not https option.

const https = s => s.replace('http://', 'https://')
options.baseURL = https(options.baseURL)
options.browserBaseURL = https(options.browserBaseURL)
}
@@ -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')
})

0 comments on commit 6f82570

Please sign in to comment.