0

I have an array of video paths that I want to play in REACT. The issue is that the videos are outside of the public dir.

Any ideas on how to make this work?

kader
  • 1
  • Hi, could you be little more clear in explaining the problem? What do you mean by "outside of the public dir?" . – kartik Jul 31 '21 at 17:41
  • The videos are stored in a directory outside of the directory of the project so I couldn't just import them directly. – kader Aug 11 '21 at 12:07

2 Answers2

0

If your link is a web URL, then you can use tag with href attribute to link your video on the web.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a

0

Ok, so I guess the problem boils down to the following statement -

"You want to serve a few videos saved in a particular directory of your server so that your react application can play them".

Well, in that case, it is somehow like you want to make these videos publically available, so why don't you just move them to a public dir, or make the directory they are in a public one, you can use any web server like nginx to do that. see the following link Use nginx to serve static files from subdirectories of a given directory.

Please note that this solution will make your videos public. If you want only authenticated users to access your video, you should consider making a video streaming api on your server see this link for how to do this in nodejs https://dev.to/abdisalan_js/how-to-code-a-video-streaming-server-using-nodejs-2o0

kartik
  • 583
  • 8
  • 24