feat: custom response header support
This commit is contained in:
parent
33d6ea94b8
commit
f30159adc6
2 changed files with 5 additions and 0 deletions
|
|
@ -35,6 +35,7 @@ from typing import (
|
|||
)
|
||||
|
||||
import click
|
||||
from werkzeug.datastructures import Headers
|
||||
from werkzeug.local import Local, LocalProxy, release_local
|
||||
|
||||
import frappe
|
||||
|
|
@ -270,6 +271,7 @@ def init(site: str, sites_path: str = ".", new_site: bool = False, force: bool =
|
|||
|
||||
local.request_ip = None
|
||||
local.response = _dict({"docs": []})
|
||||
local.response_headers = Headers()
|
||||
local.task_id = None
|
||||
|
||||
local.conf = get_site_config(sites_path=sites_path, site_path=site_path, cached=bool(frappe.request))
|
||||
|
|
|
|||
|
|
@ -263,6 +263,9 @@ def process_response(response: Response):
|
|||
if hasattr(frappe.local, "conf"):
|
||||
set_cors_headers(response)
|
||||
|
||||
# Update custom headers added during request processing
|
||||
response.headers.update(frappe.local.response_headers)
|
||||
|
||||
|
||||
def set_cors_headers(response):
|
||||
if not (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue