Course contentsShow
← Web Development
Lesson 866 of 2,98215. Browser NetworkingFree lesson

Allowed HTTP Methods

Understanding Access-Control-Allow-Methods and which methods require preflight approval.

Allowed HTTP Methods

You'll learn how the Access-Control-Allow-Methods header tells browsers which HTTP methods are permitted in cross-origin requests, and when preflight approval is required.

What Are Allowed HTTP Methods?

When your JavaScript makes a cross-origin request using methods beyond the simple ones (GET, POST, HEAD), the browser must first ask the server if that method is allowed. The server responds with an Access-Control-Allow-Methods header listing which HTTP methods it permits.

Think of it like a restaurant menu: you can't order something that's not listed. The server's response to the preflight OPTIONS request is that menu—it lists which methods (PUT, DELETE, PATCH, etc.) are available for cross-origin use.

Simple Methods vs Methods Requiring Preflight

Simple methods that don't trigger preflight:

  • GET
  • POST (with simple content types)
  • HEAD

Methods requiring preflight approval:

  • PUT
  • DELETE
  • PATCH
  • Any custom methods

When you use fetch() with these methods cross-origin, the browser automatically sends an OPTIONS request first. The server must respond with:

Access-Control-Allow-Methods: GET, POST, PUT, DELETE

This tells the browser: "Yes, I accept these methods from other origins." If your requested method (say, DELETE) isn't in that list, the browser blocks the actual request before it's even sent.

Why This Matters

This security check prevents malicious sites from performing dangerous operations (like deleting data) on servers that weren't designed for cross-origin access. The server explicitly opts-in to each method.

Key Takeaway: Access-Control-Allow-Methods lists which HTTP methods a server permits for cross-origin requests; methods like PUT, DELETE, and PATCH require preflight verification before the browser allows them through.