expose icon indicating copy to clipboard operation
expose copied to clipboard

Expose and Magento 2

Open robbanl opened this issue 1 year ago • 1 comments

Hello,

I haven't had time yet to look through the code, but I'll post an issue here as a start.

I work mainly with Laravel but also Magento 2. I tried today to create a tunnel for a Magento 2 site, using the command below. The site and components are running inside my local Docker environment, so http://127.0.0.1 will give the response.

expose share http://localhost --subdomain=mycustomsubdomain

The problem (one of them) with Magento is that you are required to input the store domain in the database. I set this to mycustomsubdomain.domain.tld. Visiting http://127.0.0.1 will then redirect me to mycustomsubdomain.domain.tld.

When I started the share, there was a redirect loop when visiting mycustomsubdomain.domain.tld. Checking the $_SERVER values I noticed that HTTP_HOST and SERVER_NAME was set to "localhost".

I haven't dug yet inside Magento 2, but as a quick fix, I added the following to lines inside index.php:

$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_ORIGINAL_HOST'];
$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_X_ORIGINAL_HOST'];

And everything started to work as expected.

The reason I'm starting out here, is because using a competitor to expose.dev, you are just entering the port number (80 in my case) and it works out of the box.

robbanl avatar Feb 16 '23 12:02 robbanl