Skip to content

Request object does not have query object populated #4485

Open
@TheOwlDude

Description

@TheOwlDude

Runtime

node.js

Runtime version

20.11.1

Module version

21.3.3

Used with

Both standalone (local development) and as an AWS lambda handler. Both exhibit the problem

Any other relevant information

We have very simple configuration.

This is the server config.

const serverConfig: Hapi.ServerOptions = {
port: process.env.SERVICE_PORT || 8400,
routes: {
cors: {
origin: ['*'],
additionalHeaders: ['x-api-key'],
},
validate: {
failAction: handleError,
options: {
abortEarly: false,
},
},
json: {
space: 4,
}
},
};

We don't create route objects per route we just add these lines to classes that implement Controller

@controller('/v1/route')
export class ExampleController1 implements Controller {
public baseUrl!: string;
public routes!: () => Array<Hapi.ServerRoute>;
}

We configure the routes on the server like this

export default class Router {

public static async loadRoutes(server: Hapi.Server, dependencies : ServiceDependencies): Promise {
server.route([
...new ExampleController1().routes(),
...new ExampleController2().routes(),
]);
}

When our route handlers are called it is always the case that request.query == {} regardless of the query parameters added to the url.

How can we help?

It would be lovely if you could explain how we can fix our configuration so that we receive query string parameters in the request object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportQuestions, discussions, and general support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions