Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1854

fetch localhost without redirecting to https?

$
0
0

In the development environment, I don't want to make things complicated by using https and SSL/STL certifications.

I learned how to prevent Google Chrome from redirecting localhost to https, and a JSON object returned after entering http:/localhost:105/hello/ into the Chrome address bar.

What confused me is that the following does not work in the browser console(Inspect->Console) for https pages:

const url = new URL('http://localhost:105/hello/');fetch(url).then(response => response.json()).then(json => console.log(json))

The error reads that:

GET https://localhost:105/hello/ net::ERR_SSL_PROTOCOL_ERROR
Uncaught (in promise) TypeError: Failed to fetch
at :1:1

And adding parameter {redirect: 'manual'} in the fetch method doesn't help.

Thanks to @novavanity. It does work on the page with the url http://localhost:105/hello/

I don't know why and how the http was redirected to https? How can I prevent that?


Viewing all articles
Browse latest Browse all 1854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>