-
-
Notifications
You must be signed in to change notification settings - Fork 459
Deploying with Serverless-next.js not working RFC Custom rewrites #767
Comments
@anialamo Have you tried using the latest stable |
@danielcondemarin thanks! but how I can use @sls-next/[email protected] and together create my own serverless.js file to "copy manually" my files located in the path "public/locales/" I have this example, but this works only with serverless-next.js/serverless.
How could be this custom serverless.js requiring @serverless/core.... but avoiding the error... "service" property is missing in serverless.yml? |
@danielcondemarin please now I have in my serverless.yml like this:
And also I have in my public/locales 2 subpaths for my languages (multilang app that uses nextjs-i18next module). When I run in the browser my app deployed in AWS CloudFront with @LambdaEdge I discover my app fails. I can see in logs the following error:
I use in my i18n.js file the following path to locate my translation files: And this is the location for the translation files inside .serverless_nextjs -> assets -> public -> locales Where can I put my locales files? public/static/locales? (this gives me an error when I execute npx serverless. I do not know what to do. Some help please? |
You can try to put inside |
Ok thanks @dphang ! I will try to put my locales inside /static. |
Oh no! @dphang this also gives me this error: Is my path.resolve wrong? My translation files are located on .serverless_nextjs-> api-lambda -> assets -> static directory, but my path is "./static"... but the log file says me What is wrong? |
I think it is trying to access from local directory which would be the Lambda container. However, we do not copy any of those static files to the Lambda itself, it is only going to S3. I am not familiar with using To support it, I think we need to add ability to copy those files to Lambda handler so it can access it. I will add it the list of items for 1.19. |
@dphang ok thanks! Do you know if its available to add some javascript code in serverless.js file or something like this code for the moment?
Sorry! I dont know how to make a custom serverless.js. Or better I wait for the release 1.19 will be generated? |
Yeah, I think if you look in this: https://github.com/serverless/components/issues/522 you should be able to If it doesn't work, I think you can also try using In meanwhile I think it will be useful to add an ability for user to execute custom scripts in two parts:
|
I published the PR: #772 which is in the latest @sls-next/serverless-component 1.19.0 alpha, it should give more flexibility by letting you run custom commands in between build and deploy for Let me know if it works for you. This should be more generic - we should not try to build something specifically for next-i18next package |
Hi @dphang! thanks! I added in my serverless.yml this code:
And my file post-build.js is in the root of my app and has this code:
When I execute npx serverless or sls command in my termnal at 11seconds I see an editor (in my case SublimeText3 is open with my file post-build.js and displays me its code while the timer of my npx serverless command is stopped at: Until I close the SublimeText3 editor then the timer of command npx serverless continues deploying. And finally it finish. But nothing is added on .serverless_nextjs-> default_lambda as I expected (public -> locales -> .... files) What is wrong in my case so my script is not executed and only displays its code in an editor? |
Not sure, I think |
A lot of thanks @dphang !!!! You are excellent! This new postBuildCommands help me a lot!!! |
Thanks @dphang for adding this! I have added the same and it's working perfectly now! |
Describe the bug
Hi! I am deploying my nextjs app with module serverless-next.js: "^1.15.0-alpha.2" because I have a custom serverless.js to copy in public/locale directory my translation files. Using this code: https://github.com/serverless-nextjs/serverless-next.js/issues/383#issuecomment-667716885
And then I deployed to my AWS @LambdaEdge and also works fine!
// Add the Next SASS plugin
nextConfig = withSass(nextConfig);
module.exports = nextConfig;`
Describe the bug
Now I added recently this code in my next.confg.js for RFC - Custom Routes https://github.com/vercel/next.js/discussions/9081 but when I try to test in my server this "rewrite" fails e.g. if I write myserver.com/en/business this returns 404 error Page not found.
Actual behavior
Expected behavior
In my localhost this works fine! BUT in AWS lambda edge & CloudFront this does not work.
Screenshots/Code/Logs
My serverless.js has the following code:
I tried this link Serverless components - Build your own https://github.com/serverless/components#build-your-own
creating my own serverless.js file at root with this sample, but it always returns me this error:
"service" property is missing in serverless.yml
`
What can I do to update my MyNextJsComponent serverless.js file to allow RFC -Custom redirects/rewrites?
Thanks!!!!
Versions
serverless-next.js: "^1.15.0-alpha.2"
The text was updated successfully, but these errors were encountered: