Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 5 additions & 7 deletions api/src/routes/ical.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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/<id> but at /ctfnote/#/ctf/<id>...)
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,
});
}

Expand Down
5 changes: 0 additions & 5 deletions api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions front/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand All @@ -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";
}

Expand All @@ -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";
}

Expand All @@ -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";
}

Expand Down
2 changes: 2 additions & 0 deletions front/src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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'),
Expand Down