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

Have API url be dynamic, so that UIs for PRs can query API in respective Modal environment #17

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from src.graphql_router import graphql_router

web_app = FastAPI()
origins = ["https://modalproject.vercel.app"]
origins = ["*"]
web_app.add_middleware(
CORSMiddleware,
allow_origins=origins, # List of allowed origins
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/graphql/apolloClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { ApolloClient, InMemoryCache } from '@apollo/client';

const VERCEL_GIT_PULL_REQUEST_ID = process.env.NEXT_PUBLIC_VERCEL_GIT_PULL_REQUEST_ID;
console.log('VERCEL_GIT_PULL_REQUEST_ID', VERCEL_GIT_PULL_REQUEST_ID);
const MODAL_ENVIRONMENT_NAME = VERCEL_GIT_PULL_REQUEST_ID ? `pr${VERCEL_GIT_PULL_REQUEST_ID}` : 'dev';
const client = new ApolloClient({
uri: 'https://devennavani-dev--api-fastapi-app.modal.run/graphql',
uri: `https://devennavani-${MODAL_ENVIRONMENT_NAME}--api-fastapi-app.modal.run/graphql`,
cache: new InMemoryCache(),
});

Expand Down
Loading