【问题标题】:Send http request for api that not secure / not https in NEXTJS failed in production发送 HTTP 请求,请求在 NEXTJS 中不安全/非 https 的 api 在生产中失败
【发布时间】:2021-06-10 02:23:18
【问题描述】:

我尝试向不在 https 中托管但在 HTTP 中很热的公共 API 发送请求。它在 localhost 中一切正常,但是当我将它部署到 https url 中的 vercel 生产构建时。它给出了一个错误。

axios.get('http://api');

如何克服?

【问题讨论】:

标签: javascript api axios next.js


【解决方案1】:

它可能,但了解风险,看看也搜索“jsonp”或“cors”ajax 以下答案适用于 jQuery,但我相信如果你允许在标题中它应该工作。 Jquery AJAX: No 'Access-Control-Allow-Origin' header is present on the requested resource

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-15
    • 2022-01-21
    相关资源
    最近更新 更多