<template>
    <component
      :is="mediaTag"
      v-if="proxyUrl"
      :src="proxyUrl"
      v-bind="$attrs"
    />
  </template>
  
  <script>
  export default {
    name: 'Proxy',
    inheritAttrs: false,
    props: {
      src: {
        type: String,
        required: true
      }
    },
    computed: {
      mediaTag() {
        return 'img'
      },
      proxyUrl() {
        if (!this.src) return null
        const encodedUrl = encodeURIComponent(this.src)
        return `/api/media?url=${encodedUrl}`
      }
    }
  }
  </script>
  