We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
node.js
20.11.1
21.3.3
Both standalone (local development) and as an AWS lambda handler. Both exhibit the problem
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.
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.
The text was updated successfully, but these errors were encountered:
@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?
Sorry, something went wrong.
No branches or pull requests
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.
The text was updated successfully, but these errors were encountered: