I'm using a React plugin that processes all of my images, and it allows for two types of loading data.
// Approach 1 - working
<img src={require('./images/my-image.jpg')} />
// Approach 2 - working
import MyImage from './images/my-image.jpg';
<img src={MyImage} />
Both approaches work fine, but the problem I'm facing is:
- I'm getting my images in a response,
- they're stored on separate server.
I've tried hardcoding to see if remote server would work and it does not:
// Approach 1 - ModuleNotFoundError: Module not found: Error: Can't resolve url
<img src={require('http://example.com/images/my-image.jpg')} />
// Approach 2 - ModuleNotFoundError: Module not found: Error: Can't resolve url
import MyImage from 'http://example.com/images/my-image.jpg';
<img src={MyImage} />
How do I tackle this? Can I even require('http://absolute-address.domain')? Don't really know where to look for require
documentation when it comes to React, can't find it anywhere in the docs.