MadLordDev
MadLordDev

Reputation: 260

access flask from ajax through https

I have seen many questions related to this topic but none of them work for me. I have moved my domain to https from HTTP. On HTTP everything worked.

The problem is I have my javascript and flask on the same IP. On different ports. I send ajax request to the flask and wait for the response. In ajax URL I have https://ip, while flask output is

Running on https://0.0.0.0:5000/

I have created a self-signed certificate for the flask and I run it as

flask run -h 0.0.0.0 --cert=/etc/ssl/certs/apache-selfsigned.crt --key=/etc/ssl/private/apache-selfsigned.key

but when I try to send the data to flask from website on Chrome I get

ERR_CERT_AUTHORITY_INVALID

On Mozilla, I have tried accessing the IP, it warned me about security, then I proceeded from Mozilla browser on the IP despite the warning and the problem was solved, meaning when I tried using the same code from the domain it worked. But for other people as well for me on the chrome, it still does not work.

Upvotes: 0

Views: 199

Answers (1)

MadLordDev
MadLordDev

Reputation: 260

So, I solved it, the problem was I was sending the request to the IP. and I changed it to the domain name. and gave flask letsencrypt certificates that were previously assigned to the domain.

Upvotes: 1

Related Questions