Skip to content

Support allowedMethods per allowedUrlPrefixes? #163

@jhagestedt

Description

@jhagestedt

Is it possible to support allowed methods per URL?

currently its only possible to manage global allowed methods.

const env = new Bash({
  network: {
    allowedUrlPrefixes: ["https://api.example.com"],
    allowedMethods: ["GET", "HEAD", "POST"], // Default: ["GET", "HEAD"]
  },
});

but having the option to restrict the method per url would be more granular.

const env = new Bash({
  network: {
    allowedMethods: ["GET", "HEAD"],
    allowedUrlPrefixes: [
      "https://public-api.com", // plain string — no transforms
      {
        url: "https://ai-gateway.vercel.sh",
        methods: ["POST"], // <-- support this :)
        transform: [{ headers: { Authorization: "Bearer secret" } }],
      },
    ],
  },
});

Use case is if only certain endpoints should allow POST, not all.
Small change but general bigger security impact.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions