nodeshift / nodeshift/faas-js-runtime
Feature Request: Revisit Issue #89 — Pass all HTTP request paths (`/*`) to the user function handler
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 23
- Forks
- 22
- PR merge metrics
- No merged PRs in 30d
Description
Feature Request: Revisit #89 — Pass all HTTP request paths (/*) to the user function handler
Summary
Currently, faas-js-runtime hardcodes route registration to the root path (/) only. Any incoming HTTP request with a subpath (e.g., GET /api/users, GET /app.js, DELETE /items/123) is immediately intercepted by Fastify and rejected with a 404 Not Found response before the user's handle(context, body) function is ever invoked.
We would like to request revisiting Issue #89 and updating faas-js-runtime to pass all non-system HTTP paths to the user handler function by default.
Motivation & Comparison with Other Knative Function Runtimes
-
Parity with Other Knative Language Runtimes:
In other official Knative Functions runtimes (Go, Python, Rust, Quarkus/Java), all incoming HTTP requests regardless of path are forwarded directly to the function handler:- Go (
kn func create -l go): The standardhttp.HandlerFuncreceives all paths, andreq.URL.Pathis available. - Python (
kn func create -l python): The Flask / CloudEvents invoker matches wildcard routes (/*) and exposesrequest.path. - Rust / Quarkus: Full URI path is preserved and passed to user code.
The Node.js runtime is currently the only language implementation that restricts incoming traffic strictly to
/. - Go (
-
Knative Platform Alignment:
Knative Serving (and Kourier/Contour/Istio ingress) already forwards full request paths directly to container port 8080. The 404 restriction is introduced solely by thefaas-js-runtimewrapper package inside the container. -
Modern Serverless Use Cases:
Restricting invocations to/prevents standard Node.js serverless patterns, such as:- RESTful APIs using standard URL path parameters (e.g.,
/api/user/:id/items). - Modern routing using standard web platform APIs like the URL Pattern API (
URLPattern). - Micro-frontends or single-page applications (SPAs) that serve an HTML shell alongside static assets (
/app.js,/style.css). - Webhook listeners requiring distinct callback paths.
- RESTful APIs using standard URL path parameters (e.g.,
Currently, developers wishing to use subpaths in Node.js Knative functions are forced to use non-standard workarounds, such as tunneling the intended path through custom headers (e.g., x-request-url), which breaks standard browser requests (<script>, <link>, fetch).
Technical Details
module.exports = function use(fastify, opts, done) {
fastify.get('/', doGet);
fastify.post('/', doPost);
fastify.options('/', doOptions);
...
Because Fastify only has / registered in its route table, any request to /anything-else hits Fastify's default 404 handler and never invokes doGet / doPost.
Proposed Solution
-
Register Wildcard / Catch-All Routes:
Inlib/invocation-handler.js, register catch-all routes (orfastify.all('/*', ...)), ensuring/metrics,/health/liveness, and/health/readinessremain prioritized:module.exports = function use(fastify, opts, done) { fastify.all('/*', doInvoke); fastify.options('/*', doOptions); ... -
Backwards Compatibility:
- 100% Backwards Compatible: Existing functions that only receive root
/requests will continue to behave identically. - Functions that inspect
context.req.urlorcontext.querywill now receive real path data for all incoming requests.
- 100% Backwards Compatible: Existing functions that only receive root
Alternatives Considered
- Custom reverse proxies / middleware: Adds unnecessary operational overhead and deployment complexity.
- Header tunneling (
x-request-url): Incompatible with standard browser asset loading and standard REST clients. - Hand-rolling custom HTTP servers: Bypasses
faas-js-runtimeentirely, losing built-in CloudEvent parsing, lifecycle hooks, and Knative CLI integration.
Thank you for maintaining this project!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/invocation-handler.js by reading the existing root-path registrations and the handlers they call. Trace how metrics, health/liveness, and health/readiness routes are registered, then verify that non-system paths reach the user handler for each supported method while those system endpoints retain their existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100