admin管理员组

文章数量:1405636

import { CollectionConfig } from 'payload'
import { GetVideoUrl, VideoReward } from '@/endpoints/video.rewards'

export const Videos: CollectionConfig = { //this is video collection
  slug: 'videos',
  admin: {
    useAsTitle: 'videoTitle',
  },
  upload: {
    mimeTypes: ['video/mp4'],
    disableLocalStorage: true,
  },
  endpoints: [VideoReward, GetVideoUrl], // endpoints of video collections
  access: {      //everything is true for now anybody can access anything
    read: () => true,
    create: () => true,
    update: () => true,
    delete: () => true,
  },
  fields: [
    {
      label: 'Video Title',
      name: 'videoTitle',
      type: 'text',
      required: true,
    },
  ],
}

This is the payload.config.ts. It's not a complete file, but this is the plugin uploadthingStorage. I can upload the videos to uploadthing; there is no issue with that.

plugins: [
    payloadCloudPlugin(),
    // storage-adapter-placeholder
    uploadthingStorage({
      collections: {
        media: true,
        videos: true
      },
      options: {
        token: process.env.UPLOADTHING_TOKEN,
        acl: 'public-read',
      },
    }),
  ],

When a video gets uploaded successfully it returns some data that looks like this:

{
  videoTitle: 'dfgfgjthjgjtyj',
  _key: 'jt4nCu8PFcktO55GPaqDj361c8YpqvBkFsldo47hxGMNaSei',
  filename: 'Boat_13.mp4',
  mimeType: 'video/mp4',
  filesize: 30872861,
  createdAt: '2025-03-21T14:12:35.834Z',
  updatedAt: '2025-03-21T14:12:35.834Z',
  id: '67dd73d34c65ef7d0dbfeb36',
  url: 'http://localhost:3000/api/videos/file/Boat_13.mp4',
  thumbnailURL: null
}

You can see the URL is on localhost:3000. Why is that? I expected it would look like .

Is payload changing the URL which we get from uploadthing, or is there another cause?

本文标签: nextjsWhy do I get a localhost URL in response to video uploadStack Overflow