-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docker): temp - use hard code path for middleware to read from ot… (
#54) * fix(docker): temp - use hard code path for middleware to read from other docker container * refactor: add api key and docker url * refactor(api_key): use api key on backend to set up user * fix: keep one url for the api and asset store * fix: update default url for api * remove api rewrite completely * remove rewrites completely from the frontend --------- Co-authored-by: Gabriele Venturi <[email protected]>
- Loading branch information
1 parent
4f2efb9
commit f801138
Showing
12 changed files
with
52 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
from app import models | ||
from app.processing.process_queue import submit_process | ||
from app.repositories import process_repository, project_repository | ||
from app.repositories import process_repository, project_repository, user_repository | ||
from fastapi import FastAPI | ||
from fastapi.staticfiles import StaticFiles | ||
from .database import SessionLocal | ||
from fastapi.middleware.cors import CORSMiddleware | ||
from app.processing.file_preprocessing import process_file | ||
from .config import settings | ||
from .api import v1_router | ||
from app.schemas.user import APIKeyRequest | ||
|
||
# Initialize the FastAPI app | ||
app = FastAPI() | ||
|
@@ -57,6 +58,26 @@ def startup_pending_processes(): | |
print(f"Error in startup_pending_processes: {e}") | ||
|
||
|
||
def setup_user(): | ||
try: | ||
with SessionLocal() as db: | ||
|
||
if settings.pandaetl_api_key: | ||
user = user_repository.get_users(db, n=1) | ||
api_key = user_repository.get_user_api_key(db) | ||
|
||
if not user: | ||
user = user_repository.create_user(db, APIKeyRequest(email="[email protected]")) | ||
|
||
if not api_key: | ||
user_repository.add_user_api_key(db, user.id, settings.pandaetl_api_key) | ||
|
||
print("Successfully set up user from api key") | ||
|
||
except Exception as e: | ||
print(f"Error in setup user from api key: {e}") | ||
|
||
|
||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=["*"], # Allow all origins (for development) | ||
|
@@ -69,6 +90,6 @@ def startup_pending_processes(): | |
|
||
app.include_router(v1_router, prefix="/v1") | ||
|
||
|
||
setup_user() | ||
startup_pending_processes() | ||
startup_file_preprocessing() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1 | ||
NEXT_PUBLIC_STORAGE_URL=http://localhost:3000/api/assets | ||
NEXT_PUBLIC_API_URL=http://localhost:5328 | ||
NEXT_PUBLIC_MIXPANEL_TOKEN=f2e8a71ab2bde33ebf346c5abf6ba9fa | ||
NEXT_PUBLIC_ROLLBAR_ACCESS_TOKEN=0df0bee895044430880278e2b2a5b2d2 | ||
# NEXT_PUBLIC_BACKEND_URL=http://backend:5328 # Uncomment this if you're working with a docker setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,5 @@ | ||
const nextConfig = { | ||
swcMinify: false, // TODO - track and remove this later: https://github.com/wojtekmaj/react-pdf/issues/1822 | ||
async rewrites() { | ||
return [ | ||
// { | ||
// source: "/api/:path*", | ||
// destination: "http://localhost:5328/:path*", | ||
// }, | ||
{ | ||
source: "/assets/:path*", | ||
destination: "http://localhost:5328/assets/:path*", | ||
}, | ||
]; | ||
}, | ||
}; | ||
|
||
export default nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const BASE_API_URL = process.env.NEXT_PUBLIC_API_URL; | ||
export const BASE_STORAGE_URL = process.env.NEXT_PUBLIC_STORAGE_URL; | ||
export const BASE_API_URL = `${process.env.NEXT_PUBLIC_API_URL}/v1`; | ||
export const BASE_STORAGE_URL = `${process.env.NEXT_PUBLIC_API_URL}/assets`; | ||
export const MAX_FILE_SIZE = 20 * 1024 * 1024; // 20MB in bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters