Is the local development experience compatible wit...
# help
y
Is the local development experience compatible with the NextJS construct? I created a new api endpoint but the SST CF endpoint provided is not resolving my new nextjs api path
a
are you seeing the SST placeholder site? If you run
npm run dev
from your frontend directory, you should be able to see your site at
<http://localhost:3000/>
y
I am seeing the SST placeholder site. I typically use the local dev workflow (npm run dev), but I'm attempting to debug a remote bug.
a
if i understand correctly, you might want to do
npx sst deploy
then the provided CF endpoint would have your latest change
npx sst start
is to set up a local live development while
sst deploy
would actually do a prod-like deployment onto aws
y
I'm attempting to setup a local live development workflow that exposes my NextJS api's. I figured I could avoid a deployment.
a
doesn’t
<http://localhost:3000/api/><apiPath>
return your result?
t
@Frank needs to correct me if I'm understanding is wrong but I do not think you access nextjs apis in this way. When you run
sst start
I believe we deploy your api routes as edge functions. These aren't sst.Functions so they cannot be live debugged
I don't exactly know enough about nextjs to understand how they're exposed
I believe the cloudfront distribution forwards to the lambda
So theoretically you should be able to access it from the url you get back where there's a placeholder site but
/api/*
should go to the deployed function
y
Sadly it does not -- no worries. I'll await Frank's insights here. Thank you!
t
It's possible we skip deploying anything on local mode
f
Seems i’m late to the party 😁
@Yousef when you say you want to live debug your NextJS apis, are you referring the api routes in ur Next.js project’s
/posts/api
?
If that’s what you mean, those api routes can’t be live debugged. On
sst deploy
, Next.js builds and bundles these api routes along with getServerSideProps, getStaticProps incremental regeneration, etc, and are deployed to Lambda@Edge functions along with the CloudFront distribution. On
sst start
, a stub Next.js app is deployed, so your api routes are not deployed.
When you are running
sst start
, the only way to invoke the Next.js api routes are to also start up Next.js (ie. npm run dev), and hits
<http://localhost:3000/api/><apiPath>
like @arda suggested.
That said, it seems you can hook up VSCode debugger to Next.js
npm run dev
directly - https://nextjs.org/docs/advanced-features/debugging
Does that work for you?
y
All good I was trying to reproduce a bug in lambda but I managed to figure it out