Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • N node-http-proxy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 482
    • Issues 482
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 102
    • Merge requests 102
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • http ... PARTY!
  • node-http-proxy
  • Issues
  • #1614
Closed
Open
Issue created Oct 19, 2022 by Güven Şen@guvensen

How to get https API response body on proxyRes

Hello all!

I have an http and an https API.

When I use http API, when user login successfully I get access token on proxyRes and I add HttpOnly Cookie. This is working.

But when I use https API I can't get response body. In my opinion because the response body is encrypted.

How can I solution this problem. Is there a solution?

This my code snippet;

function interceptLoginResponse(proxyRes, req, res) {
            // Read the API's response body from 
            let apiResponseBody = ''
            proxyRes.on('data', (chunk) => {
                chunk = chunk.toString('utf-8');
                apiResponseBody += chunk
            })


            proxyRes.on('end', async () => {
                try {
                    // Extract the authToken from API's response:
                    const {access_token} = await JSON.parse(apiResponseBody);
            
                    const cookies = new Cookies(req, res, {secure: true})

                    await cookies.set('access_token', access_token, { secure:true, pat:"/", httpOnly: true, sameSite: 'Strict', expirationDate:"21 Oct 2022 07:28:00 GMT"})
                    await res.status(200).json({ success: true })
                } catch (err) {
                    reject(err)
                }
            })
        }
Assignee
Assign to
Time tracking