It was not in my plans to install the server as nginx, so my web application is launched on the node.js server. There, similar constructions are used to refer to certain pages:
on server:
if(process.env.NODE_ENV === 'production') {
app.use('/', express.static(path.join(__dirname, '../', 'client', 'dist')))
}
app.use('/api/bonds', bonds);
const port = 80;
on client:
const url = '1.2.3.4:80/api/bonds';
class BondsService {
static getBonds() {
return new Promise(async (resolve, reject) => {
try {
const res = await axios.get(url);
const data = res.data;
resolve(data.map(bond => ({
...bond
})));
} catch (e) {
reject(e);
}
})
}
I transferred my domain to cloudflare, and set the free SSL certificate to flexible mode. When I access the application through http, everything works, but when does the http give such an error:
xhr.js:178 Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://1.2.3.4/api/bonds'. This request has been blocked; the content must be served over HTTPS.
How can you fix it?