Socket CORS (#173)

This commit is contained in:
Alek Petuskey 2022-12-23 11:19:30 -08:00 committed by GitHub
parent e32ffb6aed
commit 3e8f6ffbb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 134 additions and 503 deletions

631
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -60,6 +60,7 @@ class App(Base):
self.state_manager.setup(state=self.state) self.state_manager.setup(state=self.state)
# Set up the API. # Set up the API.
self.api = FastAPI() self.api = FastAPI()
self.add_cors() self.add_cors()
self.add_default_endpoints() self.add_default_endpoints()
@ -93,6 +94,7 @@ class App(Base):
self.api.add_middleware( self.api.add_middleware(
cors.CORSMiddleware, cors.CORSMiddleware,
allow_origins=["*"], allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"], allow_methods=["*"],
allow_headers=["*"], allow_headers=["*"],
) )

View File

@ -165,7 +165,7 @@ class Endpoint(Enum):
# The event endpoint is a websocket. # The event endpoint is a websocket.
if self == Endpoint.EVENT: if self == Endpoint.EVENT:
# Replace the protocol with ws. # Replace the protocol with ws.
url = url.replace("https://", "ws://").replace("http://", "ws://") url = url.replace("https://", "wss://").replace("http://", "ws://")
# Return the url. # Return the url.
return url return url

View File

@ -71,7 +71,7 @@ def run(
raise typer.Exit() raise typer.Exit()
# Check that the template is up to date. # Check that the template is up to date.
if not utils.is_latest_template(): if frontend and not utils.is_latest_template():
utils.console.print( utils.console.print(
"[red]The base app template has updated. Run [bold]pc init[/bold] again." "[red]The base app template has updated. Run [bold]pc init[/bold] again."
) )