5

PHome page of pwa

I have installed PWA venia in frontend magento 2.3 but images are not loading.

10
  • we need more information. is the image not loaded by your browser because of a 404? Feb 28, 2019 at 10:42
  • @ Philipp Sander : Yes getting 404 error
    – srg
    Feb 28, 2019 at 11:08
  • does the file exist? Feb 28, 2019 at 11:47
  • Yes the file is there..
    – srg
    Feb 28, 2019 at 11:51
  • I have a small doubt do we need to set the media path?
    – srg
    Feb 28, 2019 at 11:52

6 Answers 6

3

I faced the same problem and was able to resolve it by creating Virtual Host (the reason why it is necessary, is to resolve the CORS erros).

You can view CORS errors when opening the 404 images in a new tab, you will get error in the console.

Create a virtual host by following all steps mentioned here. Point Virtual Host to pub directory of Magento instance.

Give that VH URL in the env file as well. This link may very help full as well.

2

Create a virtual host and point it to the pub directory instead of the root directory.

0
2

First create a virtual host for your magento root directory. If you are dont know how to setup virtual host please follow the link : https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

Next you need to edit the file named "makeMediaPath.js" which is placed in the path

pwa-studio-release/packages/venia-concept/src/util/makeMediaPath.js

Now change the following line

const mediaPath = 'http://magento23.com/pub/media/catalog';

In the above line please replace "magento23.com" with your virtual host

1
  • Thanks a lot for providing instructions to create VH. Worked perfectly for me Apr 4, 2019 at 10:32
0

Need to Create a Virtual Host and the DocumentRoot should not be the root directory of Magento 2 installed, instead of that add pub to that.

Before the line was

/Users/shuvo/WebServer/MAGENTO/PWA

now

/Users/shuvo/WebServer/MAGENTO/PWA/pub

<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot "/Users/shuvo/WebServer/MAGENTO/PWA/pub"
<Directory "/Users/shuvo/WebServer/MAGENTO/PWA/pub">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>
ServerName magento-pwa.devs
ErrorLog "/Users/shuvo/WebServer/MAGENTO/Logs/magento.devs-error_log"
CustomLog "/Users/shuvo/WebServer/MAGENTO/Logs/magento.devs-access_log" common
# Example SSL configuration
SSLEngine on
SSLCertificateFile "/usr/local/etc/httpd/certs/magento-pwa.devs.pem"
SSLCertificateKeyFile "/usr/local/etc/httpd/certs/magento-pwa.devs-key.pem"

and on pwa studio .env file set MAGENTO_BACKEND_URL like this

MAGENTO_BACKEND_URL=https://magento-pwa.devs/
0

I was facing the similar issue on localhost, tried everything but end up changing the magento entry point from root to pub directory in order to fix this issue.

Here is a cool link from devdocs on how to do it. Good Luck...

https://devdocs.magento.com/guides/v2.3/install-gde/tutorials/change-docroot-to-pub.html

0

if you are using Magento 2.4 or above version, be ensure that your Elasticsearch is running , otherwise you will tackle the same problem.

To test if elasticsearch is working run below command in terminal:

sudo systemctl status elasticsearch.service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.