Skip to content

Conversation

@harvmaster
Copy link

Add ALLOW_ORIGINS environment variable

Adds the ALLOW_ORIGINS environment variable to be set on the docker container. This is important for interfacing with the container from a website using fetch, as the browser will block the contents of the response if the appropriate headers are not present. This change ensures the headers are present on allowed origins.
It imports the middleware package from FastAPI to handle the origin matching.

Example with docker-compose

version: '3.7'

services:
  openai-whisper-asr:
    container_name: whisper
    image: onerahmet/openai-whisper-asr-webservice:latest-gpu
    ports:
      - "9000:9000"
    environment:
      - ASR_MODEL=base
      - ASR_ENGINE=openai_whisper
      - ALLOW_ORIGINS=https://example.com
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]

The default behavior is to allow any origins * (Wild cards are supported https://*.example.com)
The variable is comma separated, so adding multiple origins can be done like so:

- ALLOW_ORIGINS=https://example.com, https://second_example.com, https://third_example.com

Docs have also been updated with this information

@ayancey
Copy link
Collaborator

ayancey commented Aug 10, 2024

Adding support for CORS is a good idea, but should be disabled by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants