Skip to content
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

Api route failed to respond #51

Closed
EthanLLL opened this issue Mar 5, 2023 · 8 comments · Fixed by #208
Closed

Api route failed to respond #51

EthanLLL opened this issue Mar 5, 2023 · 8 comments · Fixed by #208

Comments

@EthanLLL
Copy link

EthanLLL commented Mar 5, 2023

Hi, the default api/hello route failed to respond when I deployed the server function to Lambda which works fine locally.
Any suggestions?
截屏2023-03-05 15 39 11

@debanjanbasu
Copy link

I'm getting the same issue.

@fwang
Copy link
Contributor

fwang commented Mar 10, 2023 via email

@niklaswallerstedt
Copy link

@EthanLLL I had similar errors using Node16, worked after upgrading to 18. Which version are you running locally?

@debanjanbasu
Copy link

@EthanLLL I had similar errors using Node16, worked after upgrading to 18. Which version are you running locally?

My local environment is on node 19, and is working fine. The issues is when I'm deploying this to SST v2 stack. I've upgraded my node version in the cloud to v18, without much help 😢.

@debanjanbasu
Copy link

If you go to 1. Ur AWS CloudWatch console 2. Find the log group for the server handler function 3. Check the recent log streams Can you share the errors you are seeing? Frank

-- https://seed.run/ Founder at SST https://sst.dev SST https://github.com/serverless-stack/serverless-stack - OS framework for building serverless apps SEED https://seed.run/ - Deploy, manage, and monitor serverless apps
On Fri, Mar 10, 2023 at 6:15 AM Debanjan Basu @.> wrote: I'm getting the same issue. — Reply to this email directly, view it on GitHub <#51 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAUMO6BR3EPQTCQGZOIF3DW3MENTANCNFSM6AAAAAAVQAL24Y . You are receiving this because you are subscribed to this thread.Message ID: @.>

2023-03-12T03:39:41.522Z 994f5842-c0fa-4a90-93a5-f9e1cc5d38f7 ERROR Error: URL is malformed "/api/hello". Please use only absolute URLs - https://nextjs.org/docs/messages/middleware-relative-urls at Object.validateURL (/var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/web/utils.js:94:15) at new NextRequest (/var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/web/spec-extension/request.js:15:21) ... 4 lines matching cause stack trace ... at StaticGenerationAsyncStorageWrapper.wrap (/var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/async-storage/static-generation-async-storage-wrapper.js:7:52) at /var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:330:151 at AsyncLocalStorage.run (node:async_hooks:345:14) at RequestAsyncStorageWrapper.wrap (/var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/async-storage/request-async-storage-wrapper.js:65:24) { page: '/api/hello', [cause]: TypeError [ERR_INVALID_URL]: Invalid URL at new NodeError (node:internal/errors:400:5) at URL.onParseError (node:internal/url:565:9) at new URL (node:internal/url:645:5) at Object.validateURL (/var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/web/utils.js:92:23) at new NextRequest (/var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/web/spec-extension/request.js:15:21) at wrapRequest (/var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:73:12) at /var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/future/route-handlers/app-route-route-handler.js:367:38 at AsyncLocalStorage.run (node:async_hooks:345:14) at StaticGenerationAsyncStorageWrapper.wrap (/var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/async-storage/static-generation-async-storage-wrapper.js:33:24) at StaticGenerationAsyncStorageWrapper.wrap (/var/task/node_modules/.pnpm/next@13.2.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/async-storage/static-generation-async-storage-wrapper.js:7:52) { input: '/api/hello', code: 'ERR_INVALID_URL' } }

@cryptoPickle
Copy link

I have the same issue but on ssr, basically when it fails, it throws me the same error. Expected behaviour would be at least for me to render 500 error on dom.

What i did for mitigate this issue is created custom 500 page, and whenever 500 happens in cloudfront i basically redirect to 500 page using cloudfront errors. Is there any other way to render 500 page from _error.js file without adding extra 500 component ?

@EthanLLL
Copy link
Author

This issue happens when using Next 13 app/api dir. I am using app/[pages] and pages/api together to workaround this.

@khuezy
Copy link
Collaborator

khuezy commented Sep 2, 2023

Is this still an issue? #208 resolves most issues. Please report a new issue if you still experience it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants