novanda1 / payload-imagekit

Send Payload CMS uploads and deletes to ImageKit
https://www.npmjs.com/package/payloadcms-plugin-imagekit
20 stars 3 forks source link

Incompatibility with Payload Cloud (and/or hosted latest Payload version) #4

Closed damnsamn closed 9 months ago

damnsamn commented 9 months ago

Issue

This plugin currently works perfectly in dev as of the latest Payload version - but doesn't function when hosted (at least on Payload Cloud).

Any new file uploaded will throw an error message on Save, "Something went wrong" with no additional context:

image

Steps To Reproduce

  1. Create a blank Payload project via npx create-payload-app@latest
  2. Install payloadcms-plugin-imagekit
  3. Configure a Media upload collection
  4. Configure the plugin via payload.config.ts
    • At this point, it should function perfectly when running locally, correctly uploading images to ImageKit and returning the correct data
  5. Host the project (in this case using a Payload Cloud free trial)
    • Ensure environment variables are correctly configured on the server
  6. Once running - any media uploads will now break as described in the issue above

Minimal Reproduction Example

https://github.com/damnsamn/payload-imagekit-bug

This repo was created using the steps to reproduce above

novanda1 commented 9 months ago

Hey, thanks for the report.

I tried to reproduce the bug and got the same error, "Something went wrong." Then I remembered that my country has a problem accessing Digital Ocean, and Payload CMS Cloud uses Digital Ocean. So, I tried turning on my VPN (France), hit the save button again, and it worked.

To make sure it only happens in Payload CMS Cloud/Digital Ocean, I tried deploying it on Northflank, and it worked without VPN.

Payload CMS Cloud using VPN (France) :

Screenshot 2024-01-11 at 12 21 07 PM

Northflank without VPN :

Screenshot 2024-01-11 at 11 59 34 AM
damnsamn commented 9 months ago

Thanks for that Novanda. I live in Australia (which as far as I know has no restrictions re: Digital Ocean). Are you suggesting this is a Payload Cloud issue? Will be happy to raise it with them if so

novanda1 commented 9 months ago

I think the error came from the cloud storage plugin; I tried to comment out this line and the error is gone.

damnsamn commented 9 months ago

Good catch! It looks like the Payload Cloud default file storage configuration conflicts with this package - which is probably to be expected 🤦

In order to function correctly on Payload Cloud, users will need to disable storage in the config, like so in payload.config.js:

// ...
plugins: [
  payloadCloud({
    storage: false, // Disable file storage
  }),
  imagekitPlugin({ /* ... */ })
],
// ...

I think an update to this project's README is all that's necessary here.