id = 9
title = "The Digital Detour"
instructions = """
URLs aren't always permanent. Sometimes a resource moves. When this
happens, the server sends a Redirection status code (like 301 or 302)
along with a `Location` header pointing to the new address.

By default, `curl` will show the redirect message but NOT follow it.
To tell `curl` to automatically follow the trail, use the `-L` flag.

---

Briefing:
While working with the store’s systems, you stumble upon a legacy
endpoint that has been migrated. However, it seems the migration
was done in stages, leaving behind a long trail of breadcrumbs!

Base URL: http://localhost:8080

Available endpoints:
  GET  /old-archive      : The legacy location
  GET  /new-secure-vault : The new destination

Your mission:
  1. Encounter the Detour: Try fetching `/old-archive`. Notice the
     301 status. Use `-i` to find the `Location` field in headers.
  2. Follow the Trail: You *could* manually follow all 10 redirects,
     but there's a better way! Use `-L` to tell `curl` to automatically
     follow all redirects until it hits the final 200 OK.
  3. Retrieve the Code: At the final destination, you'll find the
     'Archive Access Code'.

Pro Tip: Combine `-i` and `-L` to see the entire chain of headers as
`curl` hops from one URL to the next!

---

"""

solutions = [
    """# 1. See the redirect message
curl http://localhost:8080/old-archive""",
    """# 2. Inspect headers to find the 'Location'
curl -i http://localhost:8080/old-archive""",
    """# 3. Follow the trail to the final destination
curl -L http://localhost:8080/old-archive""",
]

submit_prompt = "What is the Archive Access Code?"

[setup]
seed = [
    "CREATE TABLE IF NOT EXISTS system_logs (id INTEGER PRIMARY KEY, message TEXT)",
    "INSERT INTO system_logs (message) VALUES ('Redirect quest initialized')"
]

[server]
port = 8080

[verify.input]
contains = ["FOLLOW_THE_LIGHT_99"]
error = "You didn't reach the final destination. Did you use the -L flag to follow the redirect?"

