Skip to content

Error on rewrites to HTTPS server with self-signed certificate #45743

@thany

Description

@thany

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information


    Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 18.13.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.1.6
      eslint-config-next: 13.1.6
      react: 18.2.0
      react-dom: 18.2.0

warn  - Latest canary version not detected, detected: "13.1.6", newest: "13.1.7-canary.8".
        Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
        Read more - https://nextjs.org/docs/messages/opening-an-issue

Which area(s) of Next.js are affected? (leave empty if unsure)

Middleware / Edge (API routes, runtime)

Link to the code that reproduces this issue

N/A

To Reproduce

Add the rewrites option to next.config.js and point it to a HTTPS server that has a self-signed certificate.

Sorry, no reproduction repo. This is literally all it takes to reproduce the error. In what way you choose to set up a server with a self-signed certificate, will vary from evironment to environment. I'm sure you're able to do it 😉

Describe the Bug

Error in the CLI:

error - Error: self-signed certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1545:34)
    at TLSSocket.emit (node:events:513:28)
    at TLSSocket._finishInit (node:_tls_wrap:959:8)
    at ssl.onhandshakedone (node:_tls_wrap:743:12) {
  code: 'DEPTH_ZERO_SELF_SIGNED_CERT'

This is with NODE_TLS_REJECT_UNAUTHORIZED=0 already set.

Expected Behavior

On a development environment I don't give a fluff about certificates. I just need stuff to work. Ignore certificates, ignore their errors, and just carry on. No error, just "do it".

There is no option anywhere to be found to forcibly ignore any errors and just let it carry on. On a development pc, this is perfectly reasonable. And before you start arguing: it is perfectly reasonable. Your development team might not agree, but mine does, so if you have whatever workaround, good for you, but I need an actual solution.

I'm not going to import certificate files into an environment variable either. That too, is a workaround, and a pretty rough one at that, as it's different on each developer's pc. This totally flushes away the paradigm of "pull, install packages, run".

I promise to not ignore certificate problems on production 😘

Which browser are you using? (if relevant)

Firefox 109

How are you deploying your application? (if relevant)

Not yet at all, still in POC phase

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.please add a complete reproductionPlease add a complete reproduction.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions