Skip to content

fix: replace https to server to support Webpack 5 #11806

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

luffy84217
Copy link

@luffy84217 luffy84217 commented Dec 20, 2021

Describe the bug

Project CRA 5, with a .env.development.local file configured with HTTPS settings, gives deprecation warning.

Actual behavior

A deprecation warning is issued on bootstrap, app still works properly.
Screenshot:
image

Core idea

Replace https: getHttpsConfig(): { cert: Buffer; key: Buffer; } | boolean
with server: getServerConfig(): "http" | "https" | { type: "https"; options: { cert: Buffer; key: Buffer; }; }

function getServerConfig() {
  const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
  const protocol = HTTPS === 'true' ? 'https' : 'http';

  if (protocol === 'https') {
    if (SSL_CRT_FILE && SSL_KEY_FILE) {
      const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
      const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
      const config = {
        type: protocol,
        options: {
          cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
          key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
        },
      };

      validateKeyAndCerts({ ...config.options, keyFile, crtFile });
      return config;
    }
    return protocol;
  }
  return protocol;
}

Modify the function to move https config into "server" options and align schemas

After fixing

The deprecation warning is eliminated successfully.
Screenshot:
image

@raix raix added this to the 5.0.1 milestone Jan 9, 2022
@luffy84217
Copy link
Author

@iansu @mrmckeb Would you please take a look at this?

@carlosparreno
Copy link

@iansu @mrmckeb Would you please take a look at this?

Hello, any update on this, please? Thanks a lot in advance.

@iansu iansu modified the milestones: 5.0.1, 5.0.2 Apr 12, 2022
@vHeemstra
Copy link

Still there: [DEP_WEBPACK_DEV_SERVER_HTTPS] DeprecationWarning: 'https' option is deprecated. Please use the 'server' option. warning when using the HTTPS option.
Seems like an easy merge of this PR.. :)

@luffy84217
Copy link
Author

luffy84217 commented Apr 26, 2022

@vHeemstra Yes, but no one takes a look at this and approves the PR :(

@ivorscott
Copy link

LGTM. Can we merge this?

@blendPOS
Copy link

Has there been any progress?

@artyom-88
Copy link

Hi @iansu @mrmckeb, could you review the PR please?

@rileyjshaw
Copy link

Thanks for fixing this, I hope it gets merged soon!

@larsschenk
Copy link

Another year+ and still open and not merged or am I missing something?

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

Successfully merging this pull request may close these issues.