Skip to content

Commit

Permalink
make redirects toggleable
Browse files Browse the repository at this point in the history
  • Loading branch information
nikooo777 committed Oct 10, 2022
1 parent a7cfa64 commit 3c6b660
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"security": {
"admin_token": "mirageadmin"
},
"redirect_special": false,
"local_db": {
"host": "mysql",
"user": "mirage",
Expand Down
3 changes: 2 additions & 1 deletion server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/gin-gonic/gin"
"github.com/lbryio/lbry.go/v2/extras/errors"
"github.com/spf13/viper"
)

func getOptimizationParams(c *gin.Context) (width int64, height int64, quality int64, err error) {
Expand Down Expand Up @@ -50,7 +51,7 @@ func handleExceptions(c *gin.Context, width int64, height int64, quality int64,
urlToProxy := extractUrl(c)
imgurUrl := regexp.MustCompile(`^https?://i?\.?imgur\.com/.+?$`)
// temporarily disable imgur proxying because of throttling
if imgurUrl.MatchString(urlToProxy) {
if viper.GetBool("redirect_special") && imgurUrl.MatchString(urlToProxy) {
c.Redirect(http.StatusTemporaryRedirect, urlToProxy)
return true
}
Expand Down

0 comments on commit 3c6b660

Please sign in to comment.