serverless-next.js | ⚡ Deploy your Next.js apps | Cloud Functions library
kandi X-RAY | serverless-next.js Summary
kandi X-RAY | serverless-next.js Summary
A zero configuration Next.js 10/11 serverless component for AWS Lambda@Edge aiming for full feature parity. Please review features for a list of currently supported features.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of serverless-next.js
serverless-next.js Key Features
serverless-next.js Examples and Code Snippets
Community Discussions
Trending Discussions on serverless-next.js
QUESTION
My team and I are using Serverless Components (for NextJS - https://github.com/serverless-nextjs/serverless-next.js) and it works great, except...
Every time one of us deploys, we seem to create a whole new instance on the AWS account. Is there a way to target the same instance? Or do I need to just manually set every ARN for every role, Lambda, etc?
...ANSWER
Answered 2021-Mar-23 at 19:47Per https://github.com/serverless-nextjs/serverless-next.js/issues/962#issuecomment-805185061
You need to find a way to share your .serverless dir. If you only have one environment then you can add the directory to git. Otherwise search for "Multi-stage deployments" in the repo for some suggestions.
QUESTION
I am new to AWS CloudFront and AWS in general. I have a Next.js (React SSR framework) website which I deployed onto AWS using serverless-nextjs
(https://github.com/serverless-nextjs/serverless-next.js). However, I also need some sort of caching for my web app. I decided to use redis ElastiCache from AWS. I created an redis ElastiCache Cluster on the AWS console.
My attempt:
I setup the code for connecting to the redis ElastiCache like this:
...ANSWER
Answered 2021-Jan-09 at 06:13You can't connect to ES from outside (i.e. your local workstation) of AWS directly. ES domains are designed to be only accessible from within your resources (e.g. instances) in the same VPC as your ES domain. From docs:
Elasticache is a service designed to be used internally to your VPC. External access is discouraged due to the latency of Internet traffic and security concerns. However, if external access to Elasticache is required for test or development purposes, it can be done through a VPN.
The only way to enable connections from outside AWS to your ES is if you establish a VPN connection between home/work network or Direct Connect as explained in AWS docs:
This scenario is also supported providing there is connectivity between the customers’ VPC and the data center either through VPN or Direct Connect.
However, for quick, ad-hock setup you can use ssh tunnel between your local workstation and ES domain. This will require some jump/basion EC2 instance which the tunnel will go through.
QUESTION
I deployed my next.js
app to aws
usingserverless-next.js
package.
When I'm trying to post a big file (~1MB) to the api
route, I'm getting a 503
response code.
The full response content:
ANSWER
Answered 2020-Nov-18 at 21:16It's written here: https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html
You can't have a request + response larger than 256 KB if you upload in asynchronous mode.
Because serverless is only here to make your routes in lambda functions. If you want to upload this file, you can use S3 bucket with pre-signed url. With that you doesn't need to upload the file to the lambda function.
QUESTION
In my app, I'm sending request from getInitialProps
to an api endpoint (in /api folder).
When running my app in localhost, everything works, because it's all under same domain (localhost).
After deploying my app successfully to aws lambda (using serverless-next.js
), those requests doesn't work anymore.
The reason is that the host header when running getInitialProps
in server, is myAppBucket.s3.us-east-1.amazonaws.com
, but the app domain is https://d25q7fh11ll2cg.cloudfront.net
.
request to myAppBucket.s3.us-east-1.amazonaws.com/api/users
doesn't work but to https://d25q7fh11ll2cg.cloudfront.net/api/users
works.
But I don't have the domain data (i.e https://d25q7fh11ll2cg.cloudfront.net/api/users
) when running getInitialProps
.
I don't want to put the domain as an env var. there is another solution for this?
Also, calling directly the handler function from getInitialProps
is problematic because the handler use a server-side only packages.
Thanks
ANSWER
Answered 2020-Oct-25 at 15:49I meet a similar use case with you.
First, I suggest you to replace getInitialProps
by getServerSideProps
or getStaticProps
to make sure you call your API from server side.
getInitialProps
is deprecated, and they may run at client or server side, so they may cause unexpected behavior for your use case (our api route is server side)
Then from Next.js docs (https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering or https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation), check their small grey box:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install serverless-next.js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page