·
Last changedVersion:
This version passed the hardening gate. Hardening applied 8 targeted changes and preserved all other text. Classified findings before hardening: 0. Classified findings closed: 0. Classified findings remaining: 0. Unclassified scanner findings remaining: 0. Review findings closed: 7. Review findings remaining: 1.
None
None
Expand | File | Group | Subtype | Severity | Status |
|---|
No findings available
0 findings
When creating API endpoints with Encore.ts, follow these patterns:
Always define explicit TypeScript interfaces for request and response types:
| Option | Type | Description |
|---|---|---|
| string | HTTP method: GET, POST, PUT, PATCH, DELETE |
| string | URL path, supports |
| boolean | If true, accessible from outside (default: false) |
| boolean | If true, requires authentication |
| boolean | If true, redacts request/response payloads from traces |
Encore supports four endpoint configurations:
Include an HttpStatus field in your response to return custom status codes:
Before acting on an ID from the path or query, check that the authenticated caller is allowed to access that resource. For example, compare the caller user ID with the resource owner. If they do not match, throw an APIError with the PermissionDenied code or use APIError.notFound.
This example only shows how to bind a header value. A signature header read in a typed endpoint is not proof of authenticity. For real webhooks, check the signature against the raw request body using api.raw, as described in the encore-webhook skill.
Cookie values are untrusted client input. Validate any session or identity on the server, preferably in an Encore auth handler, and treat the raw cookie as unverified in endpoint logic. Endpoints that receive session cookies should also set the sensitive option to true so their payloads are redacted from traces.
Encore validates requests at runtime using TypeScript types. Add constraints for stricter validation:
Use & for AND logic (must pass all rules) and | for OR logic (must pass at least one):
| Validator | Applies To | Example |
|---|---|---|
| number |
|
| number |
|
| string, array |
|
| string, array |
|
| string |
|
| string |
|
| string |
|
| string |
|
| string |
|
Invalid requests return 400 with details. The shape below is illustrative only and the exact format may vary by Encore version, so treat the details structure as informational rather than a fixed contract:
Use APIError for proper HTTP error responses:
| Code | HTTP Status | Usage |
|---|---|---|
| 404 | Resource doesn't exist |
| 400 | Bad input |
| 401 | Missing/invalid auth |
| 403 | Not allowed |
| 409 | Duplicate resource |
Serve static files (HTML, CSS, JS, images) with api.static:
*path - Standard wildcard: matches all paths under the prefix (e.g., /static/*path)!path - Fallback routing: serves static files at domain root without conflicting with other API endpoints. Use this for SPAs where unmatched routes should serve index.htmlEvery file in the served directory becomes public. Point it only at a dedicated build output or asset directory, never the project or service root, and make sure it holds no environment files, source maps, keys or other secrets.
import not requireexpose: true only for public endpointsauth option to true. This requires a configured auth handler. Leave it off only for endpoints that are meant to be public, such as sign up. The examples above leave it off for brevity.APIError instead of returning error objectsapi.raw — see the encore-webhook skillMin, MaxLen, etc.) for user inputsensitive option to true on endpoints whose payloads include credentials, tokens, session data or personal data such as emailsGet started with chainctlchainctl skill install public/encoredev/api:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.cgr.dev/public/github.com/encoredev/encore/api:latest
Apache-2.0
HARDENING.md
LICENSE
SKILL.md