Skip to content

Commit

Permalink
Fix Modal hydration error (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
devennavani authored Jan 18, 2024
1 parent 2640d41 commit 75b254d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci_cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,4 @@ jobs:
- name: Deploy Modal stubs as applications
working-directory: ./backend
run: |
poetry run modal deploy src.api.app
poetry run modal deploy src.modal_functions.functions
poetry run modal deploy src.common
2 changes: 2 additions & 0 deletions backend/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .api.app import fastapi_app
from .modal_functions.functions import square
10 changes: 5 additions & 5 deletions backend/src/api/app.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
"""Module containing the FastAPI app."""
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from modal import Image, Stub, asgi_app
from starlette.middleware.cors import CORSMiddleware
from modal import Image, asgi_app
from src.api.graphql_router import graphql_router
from src.common import stub

# Construct FastAPI app
web_app = FastAPI()
web_app.include_router(graphql_router)
origins = ["*"]
web_app.add_middleware(
CORSMiddleware,
allow_origins=origins, # List of allowed origins
allow_origin_regex='https://modalproject-.*\.vercel\.app',
allow_credentials=True, # This allows cookies and credentials to be sent along with the requests.
allow_methods=["*"], # Allows all methods
allow_headers=["*"], # Allows all headers
)
web_app.include_router(graphql_router)

stub = Stub("api")
# TODO: Construct Modal image directly from pyproject.toml
image = Image.debian_slim().pip_install("strawberry-graphql[debug-server,fastapi]>=0.217.1,<1.0.0")

Expand Down
3 changes: 3 additions & 0 deletions backend/src/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from modal import Stub

stub = Stub("modalproject")
4 changes: 1 addition & 3 deletions backend/src/modal_functions/functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from modal import Stub

stub = Stub("functions")
from src.common import stub

@stub.function()
def square(num: int):
Expand Down

0 comments on commit 75b254d

Please sign in to comment.