Hi
I’m testing locally Strapi as back-end and Gridsome as front-end. I tried to generate my test site and upload it to a test host, but I have a problem with the images.
Online the url of the images is http://mysite.xyz/uploads/4_f770bb0600.jpg
, but when I do the gridsome build that folder is not created, in fact it references the upload folder of Strapi which locally works fine, via this string:
<g-image class="img-fluid" :src="`http://localhost:1337${event.node.image[0].url}`"/>
How can I solve this?
I solved it by uploading the /uploads/ folder on the host, I know it’s a very unintelligent way
I am actually trying to solve this problem as well. There has to be a way to config the build process for static sites that will be dropped into a normal web server. I am using gridsome on the frontend and only using strapi to do the hard work in dev mode. So all the images use this link on the web server
http://localhost:1337/uploads/Yht_F_Req_a77ce20079.jpg
All I want to be able to do is get rid of the localhost:1337 and maybe be able to state where the uploads folder is ex. /about/uploads/image.png
You can set a .env file for build where store remote images
Actually, I think that I found the problem and it is on the gridsome side. Here is the code that I think is the culprit
export function getStrapiMedia(url) {
// Check if URL is a local path
if (url.startsWith(’/’)) {
// Prepend Strapi address
const strapiUrl = process.env.GRIDSOME_STRAPI_URL || ‘http://localhost:1337’
return strapiUrl + url
}
// Otherwise return full URL
return url
}
I just do not know how to change it. Yet
hello
you have to add a file called .env in your gridsome root with a single string:
process.env.GRIDSOME_STRAPI_URL=to your online url
on build gridsome will get variable for the url you set in .env file