Feature #3578
Support for Dynamic Origin servers
Status:
New
Priority:
High
Assignee:
-
Start date:
05/30/2024
Due date:
% Done:
0%
Estimated time:
Description
Change call_openai_api to the following where allowed_origins is populated by runtime config
def call_openai_api(request): # ... (your existing POST request and prompt handling logic) ...
origin = request.headers.get('Origin')
- Check if origin is in the allowed origins list
if origin in allowed_origins:
- Call the helper function
result = generate_text(prompt) # ... (rest of the logic for successful requests)
- Create the response headers dictionary (allow the specific origin)
headers = {
'Access-Control-Allow-Origin': origin, # Use the specific origin here
'Access-Control-Allow-Methods': 'POST',
No data to display