fix(http): analytics.flisk.si answers POST, PUT and DELETE on / with 200 and the full home page instead of 405

Open Beginner friendly
#24 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
api, backend

Research direction

Start in the Worker's fetch handler where the home route is registered for every method; compare it with the host.flisk.si Worker, which already returns 405 for POST. Reproduce first with curl -s -o /dev/null -w "%{http_code}\n" -X POST https://analytics.flisk.si/, then write the failing test for POST/PUT/DELETE on / expecting 405 plus an Allow: GET, HEAD header. Done means those three verbs return 405, GET and HEAD still return 200, the tracking endpoint that needs POST is untouched, and the existing test suite still passes.

Written by the indexing model from the issue text.

Description

agents area: runtime automation chore cli consistency dependencies developer-experience difficulty: easy documentation enhancement good first issue help wanted hygiene json-output priority: P3 starters tests

Problem

https://analytics.flisk.si/ answers POST, PUT and DELETE with 200 and the full 13.8 KB home page, the same as a GET. A page route should only accept GET and HEAD and answer anything else with 405 Method Not Allowed and an Allow header. host.flisk.si already does this (POST returns 405).

Reproduce:

  • curl -s -o /dev/null -w "%{http_code}\n" -X POST https://analytics.flisk.si/ prints 200
  • the same with -X PUT and -X DELETE prints 200

Root Cause Analysis

The home route is registered for every HTTP method, so the Worker renders the page whatever the verb. Clients and scanners that probe with write verbs get a success status, which hides mistakes (a script posting to the wrong URL looks like it worked) and wastes a Worker run and 13 KB per request.

TDD Fix Plan

  1. RED: Add a test that POST / returns 405 with an Allow: GET, HEAD header.
    GREEN: Register the home route for GET only (HEAD is allowed by the router) and add a catch-all 405 for other verbs.
  2. RED: Add a test that PUT and DELETE on / return 405.
    GREEN: Cover them with the same handler.
  3. RED: Add a test that GET and HEAD / still return 200.
    GREEN: Keep the existing route working.

REFACTOR: Reuse the method guard on the other page routes.

Acceptance Criteria

  • POST, PUT and DELETE on / return 405 with an Allow header
  • GET and HEAD on / still return 200
  • The tracking endpoint that needs POST is unchanged
  • All new tests pass
  • Existing tests still pass
Dominant language
JavaScript
Stars
0
Forks
2
Avg merge
1h 33m
Merged PRs (30d)
7

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flisk-sh/analytics

All issues in flisk-sh/analytics

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.