Project

General

Profile

Feature #3578

Support for Dynamic Origin servers

Added by Ram Kordale 6 months ago.

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')
  1. Check if origin is in the allowed origins list
    if origin in allowed_origins:
  1. Call the helper function
    result = generate_text(prompt) # ... (rest of the logic for successful requests)
  1. 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

Also available in: Atom PDF