Skip to content

Commit

Permalink
fix: no panic in middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Sep 26, 2023
1 parent 3e8c0ac commit 4e49ffe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [unreleased]

- Handle AWS Public URLs (ending with `.amazonaws.com`) separately while extracting TLDs for SameSite attribute.
- Return `500` status instead of panic when `supertokens.Middleware` is used without initializing the SDK.

## [0.14.0] - 2023-09-11

Expand Down
4 changes: 3 additions & 1 deletion supertokens/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ func Init(config TypeInput) error {
func Middleware(theirHandler http.Handler) http.Handler {
instance, err := GetInstanceOrThrowError()
if err != nil {
panic("Please call supertokens.Init function before using the Middleware")
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
})
}
return instance.middleware(theirHandler)
}
Expand Down

0 comments on commit 4e49ffe

Please sign in to comment.