とーますメモ

Ruby on Rails / Goなどの学習メモ

【Flask】HTTPS環境で、Ajaxを使用するページを開いたら、エラーが出た。

件名の通り、以下のようなエラーが出た

The page at 'URL' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'URL'. This request has been blocked; the content must be served over HTTPS.

原因はスラッシュ漏れ。FlaskもDjangoと同じ構造みたい。
How to Make an AJAX HTTPS GET Request Using jQuery - Stack Overflow

間違い

url  : '/search'

正解

url  : '/search/'