1,友虹查看ofd跨域问题

一,环境

  使用友虹标准版网页调用 .net core 中wwwroot中静态文件(ofd格式文件),发生错误。

二,错误信息

  Access to XMLHttpRequest at 'http://api.test.com/xxx' from origin 'http://www.test.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

三,解决

  通过错误信息,可以看出,在请求时缺少Access Control Allow Origin

  在.net core 中Startup.cs的Configure方法加入
  app.UseStaticFiles(new StaticFileOptions{
      ContentTypeProvider = new FileExtensionContentTypeProvider(new Dictionary<string ,string >{
          {".ofd","application/vnd.openxmlformats-officedocument.wordprocessingml.document"}
       }),
      OnPrepareRespose = (c) => {
          c.Context.Response.Headers.Add("Access-Control-Allow-Origin","*");
       }
  })
 
posted @   zwbsoft  阅读(150)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示