ctx.request.url
The full request URL string including path and query string.
Syntax
ctx.request.url // or ctx.url Returns
string — The raw URL string as received by Node.js (e.g. `"/users?page=2"`).
Examples
import Koa from 'koa';
const app = new Koa();
app.use(async (ctx) => {
console.log(ctx.url); // /search?q=koa&page=1
console.log(ctx.path); // /search
console.log(ctx.querystring); // q=koa&page=1
ctx.body = 'ok';
});
app.listen(3000);
Output
/search?q=koa&page=1
/search
q=koa&page=1
Notes
`ctx.url` is writable; you can rewrite it for internal redirects or
middleware that mutates the path before routing. For just the pathname
use `ctx.path`; for parsed query parameters use `ctx.query`.