Open barrysteyn opened 5 years ago
@barrysteyn Can you try rewriting your custom routes with the new routes api (https://github.com/danielcondemarin/serverless-nextjs-plugin#custom-page-routing):
Instead of pageConfig
use routes
. Something like:
routes:
- src: categories
path: categories
- src: categories
path: categories/{slug}
request:
parameters:
paths:
slug: true
- src: episode
...
Might not fix the issue but is worth a try.
Unfortunately, using routes still elicits the same problem. To give you some insight, the root folder (where package.json
is found and the serverless.yml
) has a sub-folder called client where the next config is placed. That is where my custom lambda is found. So like this:
package.json
serverless.yml
client/
next.config.js
custom-lambda-handler.js
@danielcondemarin perhaps I could share my repo with you if this would help.
Ah I bet this is because your serverless.yml isn’t in the same dir as next.config.js. There aren’t many tests to cover this. The temporary workaround would be to put serverless.yml in the same dir as next config. I’ll have a look into getting this fixed.
I will try test later on today. But it used to work just fine in the past.
Moving serverless.yml
to the same directory as next.config.js
fixes the problem. This is just to confirm this. I will probably wait for the fix (thanks so much for doing this).
One last comment: It works fine with serverless-offline without me moving serverless.yml to same folder as next.config.js
That's kinda strange? @danielcondemarin the reason why this is happening kept me thinking last night, and then I realized I could just ask you :)
@danielcondemarin Another problem we have is trying to route for static assets...
Our setup is like this:
serverless-nextjs:
nextConfigDir: ./client/
staticDir: ./client/static
customHandler: ./lambda-handler.js
routes:
- src: ./client/static/sw.js
path: sw.js
- src: category
path: category/{slug}
Both the customHandler
and sw.js
cannot be resolved.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi
Using
node10.x
. Here is my serverless.ymlHowever, I get an error on AWS:
The crazy thing is that this works perfectly when I deploy it locally using serverless-offline. It also builds perfectly. I have been forced to comment out the custom lambda.
Any ideas?