Effect CommunityEC
Effect Community11mo ago
2 replies
Florian

Solved: How to Set a Redirect Response with Custom Headers in Effect Typescript

Hi, I wonder how can I set a redirect response from an API. I need to implement an OAuth callback endpoint and I would like to redirect to my React frontend. I don't understand how to set custom response headers.

class OAuthGroup extends HttpApiGroup.make("oauth")
  .add(
    HttpApiEndpoint.get("oauth", "/oauth/callback")
      .addSuccess(S.Void, { status: 302 }) // <-- how can I add a Location  response header like: headers: { Location: "https://www.example.com" }
      .setUrlParams(
        S.Struct({ code: S.NonEmptyString, expires_in: S.NumberFromString, state: S.NonEmptyString }),
      ),
  )
Was this page helpful?