Skip to content

Commit

Permalink
don't close the tab on websocket close
Browse files Browse the repository at this point in the history
  • Loading branch information
pomdtr committed Dec 7, 2023
1 parent 10a2627 commit c33e0fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/src/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ async function main() {
});

window.onbeforeunload = () => {
ws.onclose = () => { };
ws.close();
}

Expand Down
9 changes: 9 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ func NewHandler() (http.Handler, error) {
r.Use(cors.Handler(cors.Options{
AllowedOrigins: []string{"https://local.tweety.sh"},
}))

// Middleware to set the required header for private network access
r.Use(func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Private-Network", "true")
next.ServeHTTP(w, r)
})
})

r.Get("/config", func(w http.ResponseWriter, r *http.Request) {
config, err := LoadConfig(configPath)
if err != nil {
Expand Down

0 comments on commit c33e0fc

Please sign in to comment.