Hi everyone,
I'm trying to automate tests for a web application using Cypress and I've run into a proxy error that I can't seem to solve. The error appears to be specific to my tech stack.
My Environment
- Test Framework: Cypress v14.5.3
- Application Stack: Oracle APEX 24.2.4
- Web Server: ORDS 25.2.2 running on Tomcat/Nginx (configured as a reverse proxy)
- Database: Oracle DB
Problem Description
The test consistently fails on the very first step: the login process. The flow is simple:
cy.visit()
the APEX login page.
cy.type()
the username and password into the fields.
cy.click()
the login button.
Right after clicking the login button, the test hangs. The Cypress terminal shows a proxy error, and the Cypress Test Runner shows a different, subsequent error that is a symptom of the first.
Error Messages
1. Terminal Error (Cypress Proxy)
This error repeats several times. It seems the Cypress proxy can't handle the HTTP response sent by the server (ORDS) after the login POST request.
Internal error while proxying "POST https://myapp.example.com/ords/f/app/wwv_flow.accept?p_context=..." in MaybeSendRedirectToClient:
Trailers are invalid with this transfer encoding
Error [ERR_HTTP_TRAILER_INVALID]: Internal error while proxying "POST https://myapp.example.com/ords/f/app/wwv_flow.accept?p_context=..." in MaybeSendRedirectToClient:
Trailers are invalid with this transfer encoding
at ServerResponse._storeHeader (node:_http_outgoing:535:11)
at ServerResponse.writeHead (node:_http_server:421:8)
... (stack trace)
2. Cypress Test Runner Error
This error occurs because the login failed, so the session cookie was never set. My code then fails when it tries to read that non-existent cookie.
TypeError
Cannot read properties of null (reading 'value')
The error points to this line in my custom login command:
// cypress/support/commands.js
cy.getCookie("MY_APP_SESSION_COOKIE").then($cookie => {
// The test fails here because $cookie is null
window.appCookie = $cookie.value;
});
Relevant Code
cypress.config.js
(excerpt)
I've disabled chromeWebSecurity
as is often suggested for CORS/login issues, but it hasn't helped.
const { defineConfig } = require("cypress");
module.exports = defineConfig({
e2e: {
baseUrl: 'https://myapp.example.com/ords/f/app/',
chromeWebSecurity: false,
// ... other settings
},
});
commands.js
(simplified login command)
Cypress.Commands.add('doLogin', (username, password) => {
cy.visit('login_desktop?'); // Visit the login page
cy.get('#P101_USERNAME').type(username);
cy.get('#P101_PASSWORD').type(password, { log: false });
cy.get('#P101_LOGIN').click();
// This is the step that fails because the login never succeeded
cy.getCookie("MY_APP_SESSION_COOKIE").should("exist");
});
test.cy.js
(test file usage)
describe('Test Suite', () => {
before(() => {
cy.doLogin('testuser', 'password123');
});
it('should be able to access the dashboard', () => {
// The test never gets to this point
cy.get('.dashboard-title').should('be.visible');
});
});
My Question
Has anyone else encountered this ERR_HTTP_TRAILER_INVALID
error when using Cypress with an Oracle APEX/ORDS application?
My theory is that there's a conflict between the Cypress proxy and the way ORDS issues HTTP redirects (302 responses) using Transfer-Encoding: chunked
. Are there any known configurations for Cypress, Nginx, or ORDS to resolve this compatibility issue?
Any help or suggestions would be greatly appreciated. Thanks!