【问题标题】:why axios call my api in http when i use a https adress当我使用https地址时,为什么axios在http中调用我的api
【发布时间】:2019-10-17 11:25:29
【问题描述】:

这是我调用 api 时遇到的错误

我的功能:

我所有的路线都可以,除了这条我不知道为什么

【问题讨论】:

  • 在应用程序的某个地方你试图点击sportmanagementsystemapi.herokuapp.com/api/user检查所有使用的api端点的出现
  • 尝试直接在浏览器中打开sportmanagementsystemapi.herokuapp.com/api/user——即https://sportmanagementsystemapi.herokuapp.com/api/user/,使用https作为协议。你会发现你被重定向到http://sportmanagementsystemapi.herokuapp.com/api/user/——也就是说,纯http,非https。代码中的 axios.post 请求也会发生同样的事情——它被重定向到那个非 https 的 URL。这就是您收到混合内容错误的原因。
  • @sideshowbarker 你是如何改变它的?在 api 中还是在我的 vue 项目中?
  • sportmanagementsystemapi.herokuapp.com 服务器需要更改,使其不会从 https 重定向到 http

标签: api vue.js heroku mixed-content


【解决方案1】:

我在我的 vuejs 项目中解决了这个问题,我写了“https://sportmanagementsystemapi.herokuapp.com/api/user/”,问题是最后的“/”就是这样的“https://sportmanagementsystemapi.herokuapp.com/api/user”,并且可以正常工作

【讨论】:

    猜你喜欢
    • 2021-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-02
    • 1970-01-01
    相关资源
    最近更新 更多