request.url

The full request URL path including the query string.

Since Fastify 5 Spec ↗

Syntax

request.url

Returns

string — The raw request URL with query string.

Examples

import Fastify from 'fastify';

const app = Fastify();

app.get('/echo', async (req) => {
  return { url: req.url, path: req.url.split('?')[0] };
});

Notes

request.url includes the query string; use request.routeOptions.url for the matched route pattern (e.g. /cats/:id) instead of the concrete path.