Introducing native HTTP headers support
May 27, 2022
3 Min Read

We're hard at work adding much requested flexibility to the Encore framework. In this week's release, we've added native support for HTTP headers in Encore APIs and authentication handlers. No more having to use only JSON!

This means you can now easily:

  • Model REST APIs like you're used to
  • Return HTTP headers
  • Use the Local Development Dashboard to see how each field will be encoded

Run encore version update to grab the latest version and experience it for yourself! – If you're new to Encore, check out the Quick Start Guide to get started building.

Improved authentication support

Encore now supports a more flexible way to express authentication handlers, using struct payloads in the same way you're used to for regular endpoints. The struct payloads can include multiple fields that can be sourced from either HTTP Headers or query strings.

That means you can do things like:

  • Implement more advanced authentication methods that go beyond simple Bearer tokens
  • Accept client_id as a query string and an API key in the Authorization header, at the same time
  • Support HTTP Basic Authentication

Improved client code generation

The Encore client code generation has received a major upgrade for both TypeScript and Go clients.

  • Support for HTTP headers
  • Support for structured authentication handlers
  • API errors are now reported as structured errors rather than strings
  • The TypeScript client now properly supports raw endpoints, including specifying the request body, HTTP method, and arbitrary fetch options

Note: The Go client now validates the provided HTTP method for calling raw endpoints. In the rare case that a raw endpoint was called without a valid Method, the behavior of the new client generator will differ by returning an error. In previous versions it instead defaulted to making a GET request.

Bug fixes and other improvements

  • Forward slashes encoded as %2F within string path segments no longer causes that path segment to be treated as two separate segments.
  • In the rare case that path segment parameters conflict with reserved keywords or names the generated names are now prefixed with _ to avoid name collisions.
  • Blank or missing auth tokens in generated TypeScript clients will no longer be sent in the Authorization header
  • The encore.Meta function now reports the correct value for the APIBaseURL field for local development (#245)
  • Encore now supports ejecting an application as a standalone docker container. See encore eject docker --help for more information.
  • A more helpful error message is now displayed when an environment cannot be found when generating a client (#118)

Thanks to all our contributors

We rely on the community to improve Encore, and we're overwhelmed by your support and encouragement. Big thanks to @ValeriaVG, @Qolzam, Prasanna Balaji, @vilhelmmelkstam, and @MaxDanielsson for your bug reports and feedback!

Join the most pioneering developer community

Developers building with Encore are forward-thinkers working on exciting and innovative products. Join the conversation on Discord to see what's going on, learn from others, and share what you're working on.

What’s next

Over the coming weeks we'll be adding much requested flexibility to the Encore framework, with improved support for things like: middleware, configuration and dependency injection. Vote on your favorite feature on the roadmap

As always, if you have questions or ideas, come tell us on Discord. We’re excited to hear your feedback! ❤️

Catch you in the cloud,
André & the Encore team