GithubHelp home page GithubHelp logo

Comments (3)

flycash avatar flycash commented on September 18, 2024

你搜出来之后可以给我们发一个PR,发到这个仓库就可以的,社区需要大家一起改进

from beedoc.

kotori2 avatar kotori2 commented on September 18, 2024

确实是……CORS这么重要的安全问题应该被重视。
https://github.com/beego/beego/blob/develop/server/web/filter/cors/cors_test.go

	recorder := httptest.NewRecorder()
	handler := web.NewControllerRegister()
	handler.InsertFilter("*", web.BeforeRouter, Allow(&Options{
		AllowOrigins: []string{"https://aaa.com", "https://*.foo.com"},
	}))
	handler.Any("/foo", func(ctx *context.Context) {
		ctx.Output.SetStatus(500)
	})
	origin := "https://bar.foo.com"
	r, _ := http.NewRequest("PUT", "/foo", nil)
	r.Header.Add("Origin", origin)
	handler.ServeHTTP(recorder, r)

但是似乎流量全都经过NewRecorder了,和正常web.Run的行为不一致。所以我也很好奇这个问题要怎么解决。

from beedoc.

kotori2 avatar kotori2 commented on September 18, 2024

确实是……CORS这么重要的安全问题应该被重视。 https://github.com/beego/beego/blob/develop/server/web/filter/cors/cors_test.go

	recorder := httptest.NewRecorder()
	handler := web.NewControllerRegister()
	handler.InsertFilter("*", web.BeforeRouter, Allow(&Options{
		AllowOrigins: []string{"https://aaa.com", "https://*.foo.com"},
	}))
	handler.Any("/foo", func(ctx *context.Context) {
		ctx.Output.SetStatus(500)
	})
	origin := "https://bar.foo.com"
	r, _ := http.NewRequest("PUT", "/foo", nil)
	r.Header.Add("Origin", origin)
	handler.ServeHTTP(recorder, r)

但是似乎流量全都经过NewRecorder了,和正常web.Run的行为不一致。所以我也很好奇这个问题要怎么解决。

Use web.InsertFilter with the same arguments.

from beedoc.

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.