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

Can not fetch https API url inside getInitialProps #6418

Closed
ducdev opened this issue Feb 23, 2019 · 1 comment
Closed

Can not fetch https API url inside getInitialProps #6418

ducdev opened this issue Feb 23, 2019 · 1 comment

Comments

@ducdev
Copy link
Contributor

ducdev commented Feb 23, 2019

Bug report

Can not fetch https API url inside getInitialProps

Describe the bug

Login.getInitialProps = async ({ req }) => {
  const res = await fetch(
    'https://domain.com/api',
    { headers: req.headers }
  );
  const data = await res.json();
  return {
    data
  };
};
request to https://domain.com/api failed, reason: write EPROTO 4459447744:error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error:../deps/openssl/openssl/ssl/s23_clnt.c:802:
FetchError: request to https://domain.com/api failed, reason: write EPROTO 4459447744:error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error:../deps/openssl/openssl/ssl/s23_clnt.c:802:

    at ClientRequest.<anonymous> (/Users/duc/dev/rm-web/node_modules/node-fetch/lib/index.js:1444:11)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at onwriteError (_stream_writable.js:417:12)
    at onwrite (_stream_writable.js:439:5)
    at _destroy (internal/streams/destroy.js:39:7)
    at TLSSocket.Socket._destroy (net.js:568:3)
    at TLSSocket.destroy (internal/streams/destroy.js:32:8)
    at WriteWrap.afterWrite [as oncomplete] (net.js:870:10)

A clear and concise description of what the bug is.

Expected behavior

It somehow should work, and return the right result.

Screenshots

image

System information

  • OS: macOS
  • Browser (if applies) Chrome
  • Version of Next.js: [e.g. 6.0.2] ^8.0.0-canary.18
@timneutkens
Copy link
Member

This doesn't sound like a Next.js issue, as Next.js doesn't implement fetch, you're importing a library for it, eg isomorphic-fetch or isomorphic-unfetch.

With relation to the error, by putting EPROTO into google:

nodejs/node#3692
nodejs/node#19359
nodejs/help#1098
https://stackoverflow.com/questions/33743044/why-would-i-be-getting-error-write-eproto-when-making-an-https-request-in-an

@lock lock bot locked as resolved and limited conversation to collaborators Feb 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants