diff --git a/apps/remix-ide/src/app/compiler/compiler-imports.js b/apps/remix-ide/src/app/compiler/compiler-imports.js index 905ede2665..18da5fa8e9 100644 --- a/apps/remix-ide/src/app/compiler/compiler-imports.js +++ b/apps/remix-ide/src/app/compiler/compiler-imports.js @@ -21,7 +21,8 @@ module.exports = class CompilerImports extends Plugin { this.fileManager = fileManager // const token = await this.call('settings', 'getGithubAccessToken') const token = globalRegistry.get('config').api.get('settings/gist-access-token') // TODO replace with the plugin call above https://github.com/ethereum/remix-ide/issues/2288 - this.urlResolver = new RemixURLResolver(token) + const protocol = window.location.protocol + this.urlResolver = new RemixURLResolver(token, protocol) this.previouslyHandled = {} // cache import so we don't make the request at each compilation. } diff --git a/libs/remix-url-resolver/src/resolve.ts b/libs/remix-url-resolver/src/resolve.ts index 5fca8647ff..4a99d8c408 100644 --- a/libs/remix-url-resolver/src/resolve.ts +++ b/libs/remix-url-resolver/src/resolve.ts @@ -25,10 +25,12 @@ interface HandlerResponse { export class RemixURLResolver { private previouslyHandled: PreviouslyHandledImports gistAccessToken: string + protocol: string - constructor(gistToken?: string) { + constructor(gistToken?: string, protocol = 'http:') { this.previouslyHandled = {} this.gistAccessToken = gistToken ? gistToken : '' + this.protocol = protocol } /** @@ -90,7 +92,7 @@ export class RemixURLResolver { async handleSwarm(url: string, cleanUrl: string): Promise { //eslint-disable-next-line no-useless-catch try { - const bzz = new Bzz({url: 'http://swarm-gateways.net'}); + const bzz = new Bzz({url: this.protocol + '//swarm-gateways.net'}); const url = bzz.getDownloadURL(cleanUrl, {mode: 'raw'}) const response: AxiosResponse = await axios.get(url) return { content: response.data, cleanUrl }