Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Client mustBeSet check fails for Set-Cookie #1092

Open
tuckers-tech opened this issue Mar 20, 2024 · 0 comments
Open

Generated Client mustBeSet check fails for Set-Cookie #1092

tuckers-tech opened this issue Mar 20, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@tuckers-tech
Copy link

Hey all! Loving Encore TS! I ran into an issue with the generated client this evening.

I have an AuthResponse defined in the following way:

export interface AuthResponse {
  cookies: Header<'Set-Cookie'>
  user: User
}

When generated, it outputs the following:

public async login(params: LoginParams): Promise<AuthResponse> {
    // Now make the actual call to the API
    const resp = await this.baseClient.callAPI("POST", `/auth/login`, JSON.stringify(params))

    //Populate the return object from the JSON body and received headers
    const rtn = await resp.json() as AuthResponse
    rtn.cookies = mustBeSet("Header `set-cookie`", resp.headers.get("set-cookie"))
    return rtn
}

The mustBeSet call for set-cookie is failing because Set-Cookie is a forbidden response header. Encore itself is setting that header correctly, but the generated client should not expect to be able to access the Set-Cookie header.

@eandre eandre self-assigned this Mar 21, 2024
@eandre eandre added the bug Something isn't working label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants