mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 04:52:10 -07:00
fix: handling CORS for api.rest
This commit is contained in:
parent
e90c6b5e2d
commit
3c1277ebbc
2 changed files with 10 additions and 0 deletions
|
@ -41,7 +41,10 @@ func (mod *RestAPI) setSecurityHeaders(w http.ResponseWriter) {
|
|||
w.Header().Add("X-Content-Type-Options", "nosniff")
|
||||
w.Header().Add("X-XSS-Protection", "1; mode=block")
|
||||
w.Header().Add("Referrer-Policy", "same-origin")
|
||||
|
||||
w.Header().Set("Access-Control-Allow-Origin", mod.allowOrigin)
|
||||
w.Header().Add("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
|
||||
w.Header().Add("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
||||
}
|
||||
|
||||
func (mod *RestAPI) checkAuth(r *http.Request) bool {
|
||||
|
@ -190,6 +193,11 @@ func (mod *RestAPI) clearEvents(w http.ResponseWriter, r *http.Request) {
|
|||
session.I.Events.Clear()
|
||||
}
|
||||
|
||||
func (mod *RestAPI) corsRoute(w http.ResponseWriter, r *http.Request) {
|
||||
mod.setSecurityHeaders(w)
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func (mod *RestAPI) sessionRoute(w http.ResponseWriter, r *http.Request) {
|
||||
mod.setSecurityHeaders(w)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue