Is it possible to enable CORS on the FastAPI server so that only the NextJS frontend can make requests to it?
I've tried the standard way below, which didn't work. Could the fix involve modifying the Next rewrite configs?
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=['http://localhost:3000', 'https://helloworld.vercel.app'],
allow_methods=["*"],
allow_headers=["*"],
)
...