Image not showing after running lng Dist

When I was running the app in development mode, it was working very fine.

after that, I added "homepage": "." in package.json and run lng dist.

then I tried to run the dist build but none of the images in the application is running.

and when I took the console, it showed the following error

[Error] [Lightning] texture load error – "Image load error" – "file:///Users/amalmohann/Documents/codebase/lightning/lightning-poc/dist/es6/static/images/rails/1.jpg"

also I could see

XMLHttpRequest cannot load file:///Users/amalmohann/Documents/codebase/lightning/lightning-poc/dist/es6/static/images/rails/1.jpg due to access control checks.

so I tired opening it using terminal with

open file:///Users/amalmohann/Documents/codebase/lightning/lightning-poc/dist/es6/static/images/rails/1.jpg

and it did opened the image for me.

what am I facing here?

How are you opening your App in de browser? It seems like you may be pointing directly to the index.html’s file location (i.e. file:///Users/amalmohann/Documents/codebase/lightning/lightning-poc/dist/es6/index.html)?

Instead you should run a webserver (such as http-server) in the correct file location and open the localhost url in your browser.

Browser policies prevent you from running XHR requests for the local filesystem, that’s why you are seeing these errors.

1 Like

In that case how can I make a build for tv app, when I tried to run the app in the webos tv it showed me the application without images.

One alternative I could think was to use a image url instead of image file, so I used the jsonPlaceHolder website to get some images and tried loading it, but I got the same kind of error

I’m also attaching the code snippets I’m using.

I’m not an expert on deploying apps on WebOs, maybe @chiefcll can guide you a bit more on that.

But by the looks of your screenshot, it seems you are running into a CORS issue with the images from and that’s why the images aren’t loading properly.