Skip to content
pablopunkPublic

About

Microservice to fetch *http* pages through *https*

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

34 Commits

Folders and files

Repository files navigation

microsec Build Status

Fetch with https all the time

The problem

Sometimes you want to fetch an insecure URL http://insecure-url.com/?example=1 from a secure server https://my-secure-server.com but you get this error:

Mixed Content: The page at 'https://my-secure-server/' was loaded over HTTPS,
but requested an insecure resource 'http://insecure-url.com/'.
This request has been blocked; the content must be served over HTTPS.

The solution

Fetch it with microsec!:

Deploy this microservice and run it with npm start. Let's say you're deployment is on this url: https://secure9000.pro.

// Javascript example
const fetch = require('isomorphic-fetch')

const url = 'https://secure9000.pro/insecure-url.com/?example=1'
fetch(url).then(/* MAGIC */)

Custom headers

The headers you send inside the request will remain intact.

fetch(url, {headers: {'Accept-Language': 'es-ES,es;q=0.8,en;q=0.6,gl;q=0.4'}})

Author

me
© 2017 Pablo Varela

About

Microservice to fetch *http* pages through *https*

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages