Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

fix: #77

Nikolai Giman9c6d33cefe43
diff --git a/api/src/App.ts b/api/src/App.ts
index cc699c2..8d985ec 100644
--- a/api/src/App.ts
+++ b/api/src/App.ts
@@ -31,7 +31,17 @@ export default class App {
protected extendApp(): void { }
protected extendMiddlewares(): void { }
+ private resolveTrustProxy(): boolean | number | string {
+ const raw = process.env.TRUST_PROXY?.trim();
+ if (!raw || raw.toLowerCase() === 'false') return false;
+ if (raw.toLowerCase() === 'true') return true;
+ if (/^\d+$/.test(raw)) return Number(raw);
+ return raw;
+ }
+
private initializeMiddlewares() {
+ this.app.set('trust proxy', this.resolveTrustProxy());
+
//add tvJson method, clien need response format like {response: data}
this.app.use((_req: Request, res: Response, next) => {
res.tvJson = function (data: any) {
diff --git a/api/src/tv-modules/sso/providers/oidc.provider.ts b/api/src/tv-modules/sso/providers/oidc.provider.ts
index 88a6d6b..38e6a2e 100644
--- a/api/src/tv-modules/sso/providers/oidc.provider.ts
+++ b/api/src/tv-modules/sso/providers/oidc.provider.ts
@@ -110,7 +110,8 @@ export class OidcProvider implements SsoProvider {
throw new Error('CSRF state mismatch — possible CSRF attack')
}
- const currentUrl = new URL(req.originalUrl, `${req.protocol}://${req.get('host')}`)
+ const callbackOrigin = new URL(this.config.oidcCallbackUrl!).origin
+ const currentUrl = new URL(req.originalUrl, callbackOrigin)
const tokens = await client.authorizationCodeGrant(config, currentUrl, {
pkceCodeVerifier: codeVerifier,
expectedState: returnedState,
diff --git a/docs/4.configuration/1.environment-variables.md b/docs/4.configuration/1.environment-variables.md
index 0835c3e..fc4df49 100644
--- a/docs/4.configuration/1.environment-variables.md
+++ b/docs/4.configuration/1.environment-variables.md
@@ -25,6 +25,7 @@ These must match your PostgreSQL setup.
|---|---|---|---|
| `APP_PORT` | No | `1401` | Port the API server listens on |
| `APP_URL` | Yes | https://app.taskview.tech | Full URL of the web app (e.g. `https://tasks.company.com`). Used for OAuth redirects and email links. |
+| `TRUST_PROXY` | No | `false` | Set when running behind a reverse proxy so `X-Forwarded-Proto`/`X-Forwarded-For` are honoured (correct `https` URLs, real client IP). Use the number of proxies in front of the app (`1` for a single Caddy/nginx), or an IP/subnet list (`10.0.0.0/8`, `uniquelocal`). Leave unset for direct access. Avoid `true` (trusts any hop, allows header spoofing). |
## Authentication