Giter Site home page Giter Site logo

跨域问题 about amis HOT 3 CLOSED

liuxiangyu1984 avatar liuxiangyu1984 commented on May 5, 2024
跨域问题

from amis.

Comments (3)

hu54301969 avatar hu54301969 commented on May 5, 2024

经典问题,要么后端配置跨域,要么前端全局适配器走axios,但还是推荐后端配置好它,就可以使用amis的默认方式了

from amis.

liuxiangyu1984 avatar liuxiangyu1984 commented on May 5, 2024

经典问题,要么后端配置跨域,要么前端全局适配器走axios,但还是推荐后端配置好它,就可以使用amis的默认方式了

后端用的是.net core,我建立一个简单的webapi来测试,结果也是提示跨域错误,在startup里面也配置了跨域的方式,我用官网上的例子就能请求成功
namespace webapi
{
public class Startup
{
public IHostEnvironment Environment { get; }
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration,IHostEnvironment environment)
{
Configuration = configuration;
Environment = environment;
}

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddCors();
    }

    public void Configure(IApplicationBuilder app,IHostEnvironment env,ILoggerFactory loggerFactory)
    {
        app.UseCors(builder => builder.AllowAnyOrigin()
          .AllowAnyMethod()
          .AllowAnyHeader());
    }
}

}

from amis.

2betop avatar 2betop commented on May 5, 2024

这个还是自行搜索 cors headers 解决吧,不管你是什么 client 都会遇到这个问题,后端返回 header 里面补上相关信息即可

from amis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.