Closed neural-loop closed 1 year ago
Hi, I was having the same issues, this happened to me when I would try to upload a picture with the same name twice. Could this be your case as well?
@tudor0 I think the issue was CORS .
@neural-loop Where should the cors settings be placed at?
Or even, do you have an example I could maybe follow?
Thanks in advance
In the middleware.js
that doesn't match this error message though.. I don't remember exactly what it was that fixed this
server.js
module.exports = ({ env }) => ({
host: env(process.env.HOST, '0.0.0.0'),
url: process.env.CLOUD_URL,
});
middleware.js
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'connect-src': ["'self'", 'https:'],
'img-src': ["'self'", 'data:', 'blob:', 'storage.googleapis.com', 'console.cloud.google.com'],
'media-src': ["'self'", 'data:', 'blob:', 'storage.googleapis.com', 'console.cloud.google.com'],
upgradeInsecureRequests: null,
},
},
},
plugins.js
upload: {
config: {
provider: "@strapi-community/strapi-provider-upload-google-cloud-storage",
providerOptions: {
serviceAccount: process.env.GCS_SERVICE_WORKER,
bucketName: process.env.GCS_BUCKET_NAME,
basePath: "media",
baseUrl: process.env.GCS_BASE_URL,
publicFiles: true,
// uniform: env('GCS_UNIFORM'),
},
},
},
In middlewares.js, did you configure the strapi::cors or is it just the default?
Cors is configured but nothing specific for gcs
Does your strapi still upload the pictures locally or just on the cloud? I am comparing my code to yours, but besides some non gcs specific differences, the code is basically the same. You stopped getting that error alltogether?
I might still be getting the error, I found that it worked when I deployed - the error I was getting was when I was testing it locally. Maybe it's something in the cloud config?
I find it wierd that even though I set the provider as the package, strapi still tries to upload to the local folder. I am guessing that when deployed is does not do that?
I think that was the case but I don't remember 100%
Describe the bug Uploading through Strapi UI the first image and the files are successfully uploaded into GC, however it errors out and doesn't seem to recognize what is going on
To Reproduce
Expected behavior Success entry to library
Screenshots
Desktop (please complete the following information):