Skip to content

Unable to set cookie when process.server is true #450

@usb248

Description

@usb248

What problem does this feature solve?

I have a serverMiddleware with a cookie parser with an internal API (with express).
// Export the server middleware

export default {
  path: '/api',
  handler: app
}

All work fine client side but when axios request is trigerred server side, axios doesn't add set-cookie. I have to do:

$axios.onResponse((resp) => {
        if(resp.headers['set-cookie'] && process.server){
            try{
                res.setHeader('Set-Cookie', [ resp.headers['set-cookie'] ])
            }catch(e) {}
        }
        return resp
    })

Why ?

This feature request is available on Nuxt community (#c131)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions