Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Unable to find a matching sales channel when using storefront:hot-proxy #147

Open
derweili opened this issue Feb 26, 2021 · 4 comments
Open

Comments

@derweili
Copy link

I installed the dev template as described in the docs, which worked well. My dev install is fully functional on the local storefront-dev.test URL.

I then created a new theme and called ./psh.phar storefront:hot-proxy

When trying to access proxy URL under http://localhost:9998/ I get following error:

Unable to find a matching sales channel for the request: http://shopware-dev.test:9998/". Please make sure the domain mapping is correct.

I then tried to add the http://localhost:9998/ as an additional domain to the sales channel but this is not possible because the port is always striped out from the URL field.

I also tried to set {% set isHMRMode = true %} in the base.html.twig template as described in many help forums but no success.

What am I doing wrong?

I'm using laravel valet as the dev environment.

@egorbecker
Copy link

I have same problem, somebody found a way to fix that?

@egorbecker
Copy link

egorbecker commented May 11, 2023

Resolved it by setting my shop url (like "http://shopware.test") as a STOREFRONT_PROXY_URL instead of "http://localhost" in .env

@kinglouie
Copy link

for anyone finding this, if your dev domain is served via https (like "https://shopware.test/) you need to also add a non https saleschannel url (like "http://shopware.test/) in the backend in order to serve the hot proxy from http://localhost:9998

@MinhVu2711
Copy link

Hi @kinglouie, may I ask if I change the proxy service port from "80:80" to "8080:80"

version: "3.8"

services:

    proxy:
        container_name: proxy
        image: dockware/proxy:latest
        ports:
            - "80:80"          # Change to "8080:80"
            - "8888:8888"
            - "9999:9999"
            - "9998:9998"
        depends_on:
            - shop1
        volumes:
            - "./proxy/shop-1.conf:/etc/nginx/conf.d/shop-1.conf"

    shop1:
      image: dockware/dev:latest
      container_name: shop1
      ports:
         - "3308:3306"
         - "2222:22"
      volumes:
         - "db_volume:/var/lib/mysql"
         - "shop_volume:/var/www/html"
      environment:
         # default = 0, recommended to be OFF for frontend devs
         - XDEBUG_ENABLED=1
         # default = latest PHP, optional = specific version
         - PHP_VERSION=8.2

....

Then what should I change for the .env and shop-1.conf files as well as the url value from the sales_channel_domain table so that my app can work well?


shop-1.conf:

server {
    listen        80;
    server_name   shop1.shopware.com;

    location / {
        proxy_pass http://shop1;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    }
}

server {
    listen                    8888 ssl;
    server_name               shop1.shopware.com;

    ssl_certificate /etc/nginx/ssl/selfsigned.crt;
    ssl_certificate_key /etc/nginx/ssl/selfsigned.key;

    location /admin {
        proxy_pass            http://shop1:8888;
        proxy_next_upstream   error timeout invalid_header http_500 http_502 http_503 http_504;
    }
    location /static {
        proxy_pass            http://shop1:8888;
        proxy_next_upstream   error timeout invalid_header http_500 http_502 http_503 http_504;
    }
    location /api {
        proxy_pass            http://shop1;
        proxy_next_upstream   error timeout invalid_header http_500 http_502 http_503 http_504;
    }
    location / {
        proxy_pass            http://shop1:8888;
        proxy_next_upstream   error timeout invalid_header http_500 http_502 http_503 http_504;
    }
}

server {
    listen                    9998;
    server_name               shop1.shopware.com;

    location / {
        proxy_pass            http://shop1:9998;
        proxy_next_upstream   error timeout invalid_header http_500 http_502 http_503 http_504;
    }
}

.env:

###> shopware/storefront ###
STOREFRONT_PROXY_URL=http://localhost
SHOPWARE_HTTP_CACHE_ENABLED=1
SHOPWARE_HTTP_DEFAULT_TTL=7200
###< shopware/storefront ###
APP_ENV=dev
APP_URL=http://shop1.shopware.com
DATABASE_URL=mysql://root:[email protected]:3306/shopware
MAILER_DSN=smtp://127.0.0.1:1025

/etc/hosts file:

127.0.0.1. shop1.shopware.com

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

4 participants