Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ALLOW_ORIGINS Environment Variable #219

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

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