cors

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cors implements CORS header handling for the Agent Protocol HTTP surface: a browser-based frontend on a different origin -- the common case, e.g. a Vite/React dev server on its own port -- cannot reach the control plane at all without this; the browser blocks the request client-side before it ever reaches application logic, which looks nothing like an auth or network error. Opt-in via langgraph.json's "cors" section, same convention as every other platform extension -- disabled (zero overhead, no headers added) unless configured, correct default for server-to-server or same-origin deployments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(cfg *Config, next http.Handler) http.Handler

Middleware adds CORS headers and answers preflight OPTIONS requests directly, before the request reaches auth or any handler -- a preflight carries no Authorization header by design (that's the whole point of a preflight: the browser checks permission before sending the real, possibly-credentialed request), so it must never be routed through auth.Middleware or it always fails.

func ParseAllowOrigins

func ParseAllowOrigins(raw []string) []string

ParseAllowOrigins trims whitespace from each configured origin -- forgiving of a trailing comma/space typo in langgraph.json, since a silently-mismatched origin string produces the same confusing "blocked by CORS, no error message" symptom as leaving it unconfigured.

Types

type Config

type Config struct {
	AllowOrigins []string
}

Config configures allowed origins. A nil Config (or nil/empty AllowOrigins) means CORS is disabled -- Middleware becomes a no-op pass-through, not "deny everything".

func (*Config) Enabled

func (c *Config) Enabled() bool

Enabled reports whether any origin is configured.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL