Hey everyone! I can't figure out how to do an HTTP...
# talk-oathkeeper
l
Hey everyone! I can't figure out how to do an HTTP redirect on error:unauthorized only when header Accept:text/html is present, otherwise return json. My oathkeeper config is in the thread below 👇
Copy code
handlers:
    json:
      enabled: true
      config:
        when:
          - request:
              header:
                accept:
                  - application/json
          - error:
              - forbidden
              - not_found
              - internal_server_error
              - unauthorized
    redirect:
      enabled: true
      config:
        to: <https://my-redirect-url/login>
        when:
          - error:
              - unauthorized
          - request:
              header:
                content_type:
                  - text/html
                accept:
                  - text/html
I have tried two orders of fallback handlers: • json • redirect And • redirect • json
Will appreciate any help! Currently I either get json always or redirect always on unauthorized (401) error