1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How to avoid "Response body object should not be disturbed or locked" for Angular 20 SSR POST...

Discussão em 'Angular' iniciado por Iago Coutinho Campos, Junho 22, 2025.

  1. My SSR frontend application is requested via an iframe. Some information comes from a form. Something like this:

    <form action="http://localhost:4200" method="post" target="iframe" id="webrtc-form">
    <input type="hidden" name="username" value="6001">
    <input type="hidden" name="password" value="senhaSegura123">
    </form>

    <iframe name="iframe" width="320px" height="530px" style="position: absolute; top: 50px;"></iframe>

    <script>
    document.getElementById('webrtc-form').submit()
    </script>


    Everything works fine until I had to add a parser to the SSR:

    app.use(express.urlencoded({ extended: true }));


    And I receive this error on the server:
    TypeError: Response body object should not be disturbed or locked

    I'm using Angular 20 and AngularNodeAppEngine to render.

    This is the entire server code:

    import {
    AngularNodeAppEngine,
    createNodeRequestHandler,
    isMainModule,
    writeResponseToNodeResponse,
    } from '@angular/ssr/node';
    import express from 'express';
    import { join } from 'node:path';

    const browserDistFolder = join(import.meta.dirname, '../browser');

    const app = express();
    const angularApp = new AngularNodeAppEngine();

    app.use(express.urlencoded({ extended: true }));

    app.use(
    express.static(browserDistFolder, {
    maxAge: '7d',
    index: false,
    redirect: false,
    }),
    );

    app.use((req, res, next) => {
    angularApp
    .handle(req)
    .then((response) => (response ? writeResponseToNodeResponse(response, res) : next()))
    .catch(next);
    });

    if (isMainModule(import.meta.url)) {
    const port = process.env['PORT'] || 4000;
    app.listen(port, (error) => {
    if (error) {
    throw error;
    }

    console.log(`Node Express server listening on http://localhost:${port}`);
    });
    }

    /**
    * Request handler used by the Angular CLI (for dev-server and during build) or Firebase Cloud Functions.
    */
    export const reqHandler = createNodeRequestHandler(app);



    How can I avoid this?

    Continue reading...

Compartilhe esta Página