I have been building a portfolio with a headless WordPress and NextJs. I wrote my own functions to get data from the GraphQl endpoint. Everything works fine. But I have media files (images, pdfs, etc..) that are stored on the WordPress CMS and imported as links to the next.Js (imported as external images). for example:
<img src="https://wordpresscms.mywebsite.com/uploads/2020/02/myimage.png" />
But I want the assets to be hosted on the nextJs website and automatically updated on every build. Is there a way to do that automatically in Next.Js? Or is this already done when I deploy my website to production?
The scenario in my mind:
- I upload the assets to the WordPress cms.
- NextJs gets the JSON data from WordPress which includes links to external assets (using the GraphQL API on build time (getStaticProps))
- NextJs downloads the assets.
- NextJs replaces the external URLs with local URLs (hosted on the same host as my NextJs website).
Thanks.