🛠️ToolsShed

Generador de Cabeceras CORS

Genera las cabeceras Access-Control correctas para tu API con un constructor visual.

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Max-Age: 86400

Preguntas Frecuentes

Implementación de Código

# Flask — cors with flask-cors
from flask import Flask
from flask_cors import CORS

app = Flask(__name__)

# Allow specific origin
CORS(app, resources={r"/api/*": {
    "origins": "https://example.com",
    "methods": ["GET", "POST", "PUT", "DELETE"],
    "allow_headers": ["Content-Type", "Authorization"],
    "supports_credentials": True,
    "max_age": 86400
}})

# Manual CORS headers in a response
from flask import make_response
@app.after_request
def add_cors_headers(response):
    response.headers["Access-Control-Allow-Origin"] = "https://example.com"
    response.headers["Access-Control-Allow-Methods"] = "GET, POST, OPTIONS"
    response.headers["Access-Control-Allow-Headers"] = "Content-Type, Authorization"
    return response

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.