Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(templates): website template video component not referring to correct resource url #11811

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

itsdapi
Copy link

@itsdapi itsdapi commented Mar 21, 2025

What?

After normally upload video to payload using website template, the video is referring to a werid url, which return 404.

https://example.com/media/main_page.mp4

Why?

At the VideoMedia component I found this. The media was hard coded into the component

  if (resource && typeof resource === "object") {
    const { filename } = resource;

    return (
      <video autoPlay className={cn(videoClassName)} controls={false} loop muted onClick={onClick} playsInline ref={videoRef}>
        <source src={`${getClientSideURL()}/media/${filename}`} />
      </video>
    );
  }

How?

After checking the props that pass to the Media component I found this url

media {
  id: 16,
  alt: null,
  caption: null,
  prefix: 'media',
  updatedAt: '2025-03-21T12:11:36.378Z',
  createdAt: '2025-03-21T12:11:19.138Z',
  url: '/api/media/file/main_page.mp4',
  thumbnailURL: null,
  filename: 'main_page.mp4',
  mimeType: 'video/mp4',
  filesize: 23786831,
  ...
}

And accessing it do get the video.

http://example.com/api/media/file/main_page.mp4

Changing the above code to this will refer to correct address.

  if (resource && typeof resource === "object") {
    const { url } = resource;

    return (
      <video autoPlay className={cn(videoClassName)} controls={false} loop muted onClick={onClick} playsInline ref={videoRef}>
        <source src={`${getClientSideURL()}${url}`} />
      </video>
    );
  }

@itsdapi itsdapi changed the title Fix website template video component not referring to correct resource url fix(templates): website template video component not referring to correct resource url Mar 21, 2025
@r1tsuu r1tsuu requested a review from paulpopus March 21, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant