-
Notifications
You must be signed in to change notification settings - Fork 156
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
Does this method work with the pages router? #2
Comments
@remusris Absolutely. Just make sure you change the path to the python file in the package.json script. |
My second question is can this be used alongside trpc? I'm referring to a t3 stack scaffold below is the t3 stack folder structure ├─ public Would you just change the code below
|
@digitros will it work with tRPC ? ^ I got it to work correctly on my localhost but for some reason Vercel isn't recognizing the Python file in src/pages/api/[dir name] |
Just following up on if anyone got this working |
I've been update to replicate on localhost, it does not rewrite for me |
It should work with the app folder too, but you can't add the file inside app folder. Create a new reference: https://vercel.com/docs/functions/serverless-functions/runtimes |
I haven't gotten it to work with the pages directory. rewrites: async () => {
return [
{
source: "/api/py/:path*",
destination:
process.env.NODE_ENV === "development"
? "http://127.0.0.1:8000/api/py/:path*"
: "/api/py",
},
];
}, it seems to be deploying to /api/index from fastapi import FastAPI, Request, APIRouter
router = APIRouter(prefix="/api/py")
@router.get("/")
def hello_world(request: Request):
return {"message": "Hello World"}
app = FastAPI()
app.router.include_router(router) which means this code never gets run |
@Wolfleader101 It works the same way in pages too. Since you mentioned As per your current setup your python code should run in |
It seems to be that it works but only on a per file basis - you can't have a fully setup fast API router, you need to have one per file... |
Yeah, I think that's a limitation when you are using Python runtime with the next js framework. To fully utilize the Python runtime like one single Python backend app you need to remove the next js files and host it with just vercel config. |
Yea seems to be a limitation with multiple project types. Hopefully they fix it in the future. |
Can you copy the code from next.config.ts in an existing pages router nextJS project to get this method to work?
The text was updated successfully, but these errors were encountered: