diff --git a/api/package.json b/api/package.json index 1df49a2f4..1b4971a3f 100644 --- a/api/package.json +++ b/api/package.json @@ -30,8 +30,7 @@ "ical-generator": "^3.2.1", "postgraphile": "^4.11.0", "postgraphile-plugin-connection-filter": "^2.1.1", - "postgres-migrations": "^5.3.0", - "slugify": "^1.6.5" + "postgres-migrations": "^5.3.0" }, "devDependencies": { "@types/express": "^4.17.11", diff --git a/api/src/routes/ical.ts b/api/src/routes/ical.ts index 80bc1fb0a..f5a58f47e 100644 --- a/api/src/routes/ical.ts +++ b/api/src/routes/ical.ts @@ -1,7 +1,6 @@ import { ICalCalendar } from "ical-generator"; import { Request, Response, Handler } from "express"; import { Pool } from "pg"; -import slugify from "slugify"; type CtfRow = { id: number; @@ -53,18 +52,17 @@ export function icalRoute(pool: Pool): Handler { const ctfs = await getCtfs(); for (const ctf of ctfs) { - // I'm not sure if this works in all cases (e.g. if ctfs aren't at /#/ctf/ but at /ctfnote/#/ctf/...) - const ctf_url = new URL( - `/#/ctf/${ctf.id}-${slugify(ctf.title)}/info`, - `${req.protocol}://${req.headers.host}` - ); + + const proto = req.headers["x-forwarded-proto"] || req.protocol; + const host = req.headers["x-forwarded-host"] || req.headers.host; + const ctf_url = `${proto}://${host}/#/ctf/${ctf.id}/info`; cal.createEvent({ start: ctf.start_time, end: ctf.end_time, description: ctf.description, summary: ctf.title, - url: ctf_url.href, + url: ctf_url, }); } diff --git a/api/yarn.lock b/api/yarn.lock index 59cba001a..6a1aaa082 100644 --- a/api/yarn.lock +++ b/api/yarn.lock @@ -2616,11 +2616,6 @@ slice-ansi@^4.0.0: astral-regex "^2.0.0" is-fullwidth-code-point "^3.0.0" -slugify@^1.6.5: - version "1.6.5" - resolved "https://registry.yarnpkg.com/slugify/-/slugify-1.6.5.tgz#c8f5c072bf2135b80703589b39a3d41451fbe8c8" - integrity sha512-8mo9bslnBO3tr5PEVFzMPIWwWnipGS0xVbYf65zxDqfNwmzYn1LpiKNrR6DlClusuvo+hDHd1zKpmfAe83NQSQ== - source-map-support@^0.5.17: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" diff --git a/front/nginx.conf b/front/nginx.conf index b67b12bfb..d476313aa 100644 --- a/front/nginx.conf +++ b/front/nginx.conf @@ -22,6 +22,8 @@ server { proxy_set_header Connection $http_connection; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $host; add_header Pragma "no-cache"; } @@ -33,6 +35,8 @@ server { proxy_set_header Connection $http_connection; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $host; add_header Pragma "no-cache"; } @@ -44,6 +48,8 @@ server { proxy_set_header Connection $http_connection; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $host; add_header Pragma "no-cache"; } @@ -55,6 +61,8 @@ server { proxy_set_header Connection $http_connection; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $host; add_header Pragma "no-cache"; } diff --git a/front/src/router/routes.ts b/front/src/router/routes.ts index d704a9a48..577261db1 100644 --- a/front/src/router/routes.ts +++ b/front/src/router/routes.ts @@ -35,6 +35,7 @@ const ctfsRoute: RouteRecordRaw = { const ctfRoute: RouteRecordRaw = { path: 'ctf/:ctfId(\\d+)-:ctfSlug', + alias: ['ctf/:ctfId(\\d+)'], name: 'ctf', redirect: { name: 'ctf-info' }, props: { @@ -54,6 +55,7 @@ const ctfRoute: RouteRecordRaw = { children: [ { path: 'task/:taskId(\\d+)-:taskSlug', + alias: ['task/:taskId(\\d+)'], name: 'task', props: (route) => ({ taskId: parseInt(route.params.taskId as string) }), component: () => import('pages/Task.vue'),