gpt4 book ai didi

javascript - 当使用 www 时,我没有得到 api 结果,如果没有 www 使用,我会得到它们

转载 作者:行者123 更新时间:2023-11-28 05:24:46 27 4
gpt4 key购买 nike

当我打开像 www.mywebsite.in 这样的页面时,它不会显示我的数据。但是,当我打开没有 www 的网站页面时,我可以从数据库中获取结果。

我使用 getpost api 来获取 json 数据,但在加载页面时出现错误:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://mywebsite.in/values/get. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

最佳答案

public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services

// Web API routes
config.MapHttpAttributeRoutes();
config.EnableCors();

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}

关于javascript - 当使用 www 时,我没有得到 api 结果,如果没有 www 使用,我会得到它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40260694/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com