curveball / core

The Curveball framework is a TypeScript framework for node.js with support for modern HTTP features.
https://curveballjs.org/
MIT License
525 stars 7 forks source link

Add a 'absoluteUrl' property to ctx.request #197

Closed evert closed 2 years ago

evert commented 2 years ago

This keeps on coming back, and maybe it is better to have a standard convention for this after all.

This also adds a ctx.request.publicBaseUrl and ctx.response.publicBaseUrl, but perhaps these should actually be called ctx.request.origin and ctx.response.origin.

This feature deliberately does not use the HTTP host header to determine the value, because this header is user-provided. Because so many security features relate to the 'origin', I want users to explicitly say what URL their app is hosted on, or otherwise we default to something that might obviously be wrong (http://localhost).

However, this origin may be provided with a process.env.PUBLIC_URI environment variable.

@spidgorny, not sure if you are still watching, but you originally asked for this in #140 . Apologies it took a few years for me to change my mind.

spidgorny commented 2 years ago

:-) It's nice you still remember me. I moved on to using nextjs though. GL.