2

When trying to develop the store front, we use bin/watch-storefront.sh

Our APP URL is http://ourshop.localhost.example.com and we have a DNS entry which points to 127.0.0.1

Now when opening the printed URL http://ourshop.localhost.example.com:9998 most of the AJAX requests do not work due to CORS errors.

This seems because the site now running at URL http://ourshop.localhost.example.com:9998 is requesting data from http://ourshop.localhost.example.com (for example when paginating throw the product filters / list.

We already tried changing the APP_URL to http://ourshop.localhost.example.com:9998 but it does not help.

How can this be solved?

EDIT

The interesting part is, that bin/watch-administration.sh does not suffer from this problems. It servers on http://localhost:8080/ and works without CORS problems.

Alex
  • 32,506
  • 16
  • 106
  • 171
  • https://stackoverflow.com/questions/31602697/webpack-dev-server-cors-issue – Alex Jul 03 '21 at 08:21
  • 2
    If the origin (top address bar) is different than the URL in the AJAX call (protocol + domain + port), CORS will kick in. You need to focus your troubleshooting on why the AJAX calls aren't based on the APP_URL variable. – Megabit Aug 12 '21 at 02:27
  • @Megabit I think they are based on the APP_URL variable, but webpack is proxying the requests, and thus the URL is different? – Alex Nov 17 '21 at 15:50

1 Answers1

0

One workaround would be to call Chrome with CORS disabled

google-chrome --disable-web-security --user-data-dir=/tmp/user$$

But I am looking for better solutions.

Alex
  • 32,506
  • 16
  • 106
  • 171