Hi. I've setup a Portfolio collection and added it to the Payload config.
I'm not receiving an error in VSCode. When I create a portfolio item and click save I receive a message 'No files were uploaded.' and console error message:
POST http://localhost:3000/api/portfolio?locale=en&depth=0&fallback-locale=null 400 (Bad Request)
Portfolio.tsx
import { CollectionConfig } from 'payload/types';
const Portfolio: CollectionConfig = {
slug: 'portfolio',
access: {
create: (): boolean => true, // Everyone can create Portfolio items
read: (): boolean => true, // Everyone can read Portfolio items
update: (): boolean => true, // Everyone can update Portfolio items
delete: (): boolean => true, // Everyone can delete Portfolio items
},
fields: [
{
name: 'title',
label: 'Title',
type: 'text',
required: true,
},
{
name: 'subtitle',
label: 'Venue Title',
type: 'text',
required: true,
},
{
name: 'backgroundImage',
type: 'upload',
relationTo: 'media',
required: true,
},
{
name: 'alt',
label: 'Alt Text',
type: 'text',
required: true,
},
],
};
export default Portfolio;
Any ideas?
(Any other suggestions to improve this code will be appreciated)
I'm using Nextjs
Are you using the Admin UI to add the Portfolio Item or are you trying to do it from your frontend with an http post request? If it's the latter, are you able to do it from the Admin UI?
AdminUI
Hmm, are you able to save other documents in other collections?
Yes the other fields work
collections*
I'm getting this error when I start the Payload server in Nextjs -
yarn run v1.22.19
$ ts-node server.ts
[20:56:14] INFO (payload): Connected to Mongo server successfully!
[20:56:14] INFO (payload): Starting Payload...
info - Loaded env from C:\git\2160\2160-Lodge-Bukela-2\.env
webpack built ab43f4191f7a65cf1eb2 in 15364ms
webpack compiled successfully
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: No serializer registered for ConcatSource
<w> while serializing webpack/lib/util/registerExternalSerializer.webpack-sources/ConcatSource -> Array { 2 items } -> ConcatSource
What if you try starting it with the default
yarn run dev
command?
Chatgpt: "It looks like there is an issue with serializing the ConcatSource object, which is causing the caching to fail. This warning message should not cause any major issues, but it might slow down your Webpack build time if the cache is not working properly.
One way to resolve this issue is to clear the Webpack cache by running yarn cache clean. You can also try updating your Webpack version or any dependencies related to Webpack to see if that fixes the issue."
So that shouldn't be part of the error
Portfolio.tsx
should be
Portfolio.ts
, shouldn't it?
Oh, yeah, I was wondering why it was tsx as well
Thanks. Error is still there.
It's working now, not sure what the fix was as my Portfolio file was named .ts the entire time. Thanks for the help.
i get this as well. i am using the "upload" configuration on the collection. when save the collection i get this error , removing it stops the error. i wonder id there is an option to not forcing uploading an image. when i scrapping some data locally, i would like to create the collection sometimes with the images and sometimes without them.
After switching to using separate repos I no longer experience errors like this.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.