Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request object does not have query object populated #4485

Open
TheOwlDude opened this issue Mar 12, 2024 · 1 comment
Open

Request object does not have query object populated #4485

TheOwlDude opened this issue Mar 12, 2024 · 1 comment
Labels
support Questions, discussions, and general support

Comments

@TheOwlDude
Copy link

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.

@TheOwlDude TheOwlDude added the support Questions, discussions, and general support label Mar 12, 2024
@TheOwlDude TheOwlDude changed the title Request object does not has query object populated Request object does not have query object populated Mar 12, 2024
@damusix
Copy link
Contributor

damusix commented Mar 13, 2024

@TheOwlDude Hard to tell what's going on and how Hapi is being used without an example to run. Is there a CodePen you can send?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

2 participants