await domain.redirects.add({ from: "www", to: "@" });
// { id, source: "www.example.com", target: "https://example.com",
// status: 308, keepPath: true, keepQuery: true, recordCreated: true }
await domain.redirects.add({ from: "@", to: "https://elsewhere.com", status: 301, keepPath: false });
await domain.redirects.list();
await domain.redirects.remove(id);domain.redirects.add(from_name="www", to="@")
# {"id", "source": "www.example.com", "target": "https://example.com",
# "status": 308, "keepPath": True, "keepQuery": True, "recordCreated": True}
domain.redirects.add(from_name="@", to="https://elsewhere.com", status=301, keep_path=False)
domain.redirects.list()
domain.redirects.remove(redirect_id)fromstringrequiredA name of the zone — www, or @ for the root.
tostringrequiredAnother name of the zone, or an absolute https address.
statusnumber308308 keeps the method; 301 is the older permanent; 302 and 307 are temporary.
keepPathbooleantrue/blog/x arrives at /blog/x. False sends everything to the target root.
keepQuerybooleantrueKeeps the query string as it was.
A CNAME does not redirect
A DNS record points a name at a machine; it never tells a browser to go elsewhere, and it cannot keep the path. That is why this is not part of records.
The name has to be seen by the edge
A rule only applies to traffic the edge sees. With nothing on the name, the call poses what is needed and says so with <code>recordCreated</code>. With a record that bypasses the edge, it answers <code>redirect_source_not_proxied</code> rather than changing how your name is served behind your back.
Removing
remove(id) drops the rule, and the record it had posed if that record served nothing else — recordRemoved says whether it did.