-
-
Notifications
You must be signed in to change notification settings - Fork 455
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
503 Error when invoking NextJS API Route from Client #936
Comments
Also, this all works fine on my local development server. This only happens when I deploy via serverless. |
So, Felix I'm experiencing the same issue and opened up another report. Your serverless.yml is super small so my guess is that you're suffering from a misconfiguration error. But I have no advice beyond that since I'm suffering from the same. |
Thanks Charles, hopefully we can get some visibility on this issue from the devs |
Check out the releases page and try some of the newer alpha versions to see if this remedies any of your issues. I see you're using 1.18.0, which lacks support for quite a few features afaik |
@felixs8696 I will fill you out on what happened with mine. At some point or another I deleted my dynamodb tables. I repopulated them and it failed to do that without telling me so I was asking my API to populate nothing. |
Thanks @jonahallibone I tried the latest alpha version @sls-next/[email protected] and it didn't work |
@mcnamara-charles So it worked after your recreated your dynamo tables? |
I added reproduction steps above, but I'll copy them here if someone has the same issue
This will result in the 503 error above. |
Everytime you update how your tables function and what type if data they hold, for example if i changed pass to password for the name of a field, you'd want to update your deployed tables. So go to aws and your dynamodb console and look for your tables. If they exist, delete them (make sure you chanfe regions and delete every table) then reupload them |
So I've got some good advice but it might take a while to write down. Basically I repurposed one of the examples "dynomodb-crud" but it sounds like this is a permissions issue. Did you give your api lambda full permissions? |
I had a similar issue in that it worked locally, but not in the cloud. In my case, the 503 error occurred when I tried to use JWT with HTTP.GET. axios
.get(`https://${API_HOST}/api/verifyToken`,
{ headers: { Authorization: `Bearer ${jwt}` } }
) but CloudFront didn't forward this header to lambda. The solution I found is one of the following:
or |
Okay @kato-takaomi-ams in your serverless.yml there should be a way to rewrite your default API Lambda to use post. Other than that I'm unable to provide guidance as I use Iron Sessions to store my session and cookie data |
@felixs8696 Does your Maybe your project has URLs like this: NextJS-API-URL: AppSync-Graphql-EndPoint: If you want to call NextJS-API, I think you should call the URL of cloudfront with axios etc. |
Thanks, but whitelisting the authorization headers didn't work for me. This is the config I am currently using
|
Okay, because I couldn't figure out how to get this to work, I've just used the graphQL API explicitly in my code instead of going through the NextJS API route, which works, but doesn't solve this problem of why it doesn't work through the API route. I'm assuming this has something to do with the Cloudfront configuration and some header not being passed through or something to the |
@felixs8696 Are you calling |
No I'm calling |
It seems that |
I am experiencing the exact same issue.
When I build and serve locally everything works fine, but when I deploy (using the serverless command) and I access my website, everything it's fine for static routes, but API routes and SSR routes all fail with a 503 and when I look into Cloudwatch, this is what I get
my
|
@KrustyC Sorry that I missed this issue, perhaps you can post the contents of the line it failed at in If it's similar to in #819, wondering if those libraries are manipulating |
@dphang thanks for coming back to me. After some more debugging, I had to remove webpack5, and that sorted out the issue. I may come back to test it again with webpack 5 and update you here in case I have more issues |
Closing old issue, feel free to comment in case this is still an issue and I'll reopen, but most likely would be better to reopen a new issue against the latest versions. |
this solved my problem |
Describe the bug
I am using Amplify's API functionality to invoke an AppSync GraphQL endpoint to resolve my API calls. But, I'm getting a GraphQL error message in my Lambda@Edge CloudWatch logs when trying to invoke my API in my application from the client side.
The weird thing is that when I try to execute the API's internal logic on the server side, everything works properly. So, this correctly retrieves and display all data in my application.
However, if if I invoke this api route, by going to
<app_id>.cloudfront.net/api/users/[username]
, I get the result under "Actual behavior".This tells me that I have set up my Cognito and identity pools correctly. For now I am just developing using an API Key, so I expect there to be no permissions barriers.
Actual behavior
If I go to
<app_id>.cloudfront.net/api/users/[username]
I receive the following error page:Expected behavior
API query response should be returned when invoked client side.
Steps to reproduce
Amplify.configure(config);
const response = await API.graphql(graphqlOperation(operation, params))
serverless.yaml
at the root of the project with the following content:serverless
. See: https://github.com/serverless-nextjs/serverless-next.jsThis will result in the 503 error above.
Screenshots/Code/Logs
Versions
Additional context
The text was updated successfully, but these errors were encountered: