Dynamic Success-URL


(Animosity022) #1

I’m using the jwt http.login to get logged in via Google Auth which is working.

Is there a way to dynamically go back to the URL that called it?

jwt {
path /
redirect /login
allow email some@example.log
log-file /opt/caddy/logs/jwt.log
log-level debug
}

login {
success-url /sonarr (I wanted this to go back to the original URL that called it)
google client_id=-someid,client_secret=somesecret,scope=https://www.googleapis.com/auth/userinfo.email
jwt_expiry 24h
cookie_expiry 2400h
}

My normal flow is to call apps.example.com/sonarr and that redirect to the login page. I’d like to return back to apps.example.com/sonarr when logged in successfully.


(Magikstm) #2

Did you try using -redirect-query-parameter?


(Animosity022) #3

I went with:

redirect /login?backTo={rewrite_uri} as I found that example and removed the success_url out from the login area.

It seems to work. Is that the same as what you are asking? If not, what would that look like with my config?


(Magikstm) #4

Yes, it’s same. The variable name is configurable if needed.