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

Watch-Scripts: Hot proxy doesn't work with https? #17

Open
Songworks opened this issue Feb 9, 2023 · 0 comments
Open

Watch-Scripts: Hot proxy doesn't work with https? #17

Songworks opened this issue Feb 9, 2023 · 0 comments
Assignees

Comments

@Songworks
Copy link

Songworks commented Feb 9, 2023

The webpack hot proxy used by the bin/watch-xyz.sh scripts doesn't seem to work at all with or over https.
Or at least I couldn't get it to work over https.

There are parts of it that seem to be hardcoded to always run over http (asset-urls, I think it was) and in the end it always failed with Client sent an HTTP request to an HTTPS server., one way or another.

I guess the Shopware developers never expected anyone to run a local environment using only https. :)

Anyway, I am writing this down in the hope that you might know a solution?
Or, if you are interested, implement one so that we can run the watchers by default in your devenv environment too?

And if it helps anyone:
So far my "solution" has been to add another caddy virtualHost with the exact same extraConfig but running over http. Plus some script aliases to use it for the watchers:

devenv.local.nix:

{ pkgs, config, inputs, lib, ... }:

{
  # HTTP Host for webpack hot-proxy to work
  services.caddy.virtualHosts."http://127.0.0.1:8001" = {
    # Same as https virtualHosts
    extraConfig = ''
      @default {
        not path /theme/* /media/* /thumbnail/* /bundles/* /css/* /fonts/* /js/* /recovery/* /sitemap/*
        not expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'})
      }
      @debugger {
        not path /theme/* /media/* /thumbnail/* /bundles/* /css/* /fonts/* /js/* /recovery/* /sitemap/*
        expression header_regexp('xdebug', 'Cookie', 'XDEBUG_SESSION') || query({'XDEBUG_SESSION': '*'})
      }

      tls internal
      root * public
      php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket}
      php_fastcgi @debugger unix/${config.languages.php.fpm.pools.xdebug.socket}
      encode zstd gzip
      file_server
      log {
        output stderr
        format console
        level ERROR
      }
    '';
  };

  # Aliases, it's necessary to set APP_URL for the watchers, otherwise the
  # hot-proxy throws `Client sent an HTTP request to an HTTPS server.`
  scripts.bstf.exec = "bin/build-storefront.sh";
  scripts.badm.exec = "bin/build-administration.sh";
  scripts.wstf.exec = "export APP_URL=http://127.0.0.1:8001 && bin/watch-storefront.sh";
  scripts.wadm.exec = "export APP_URL=http://127.0.0.1:8001 && bin/watch-administration.sh";
}

Cheers!

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

No branches or pull requests

2 participants