Commit da4c76ac authored by Eliot Berriot's avatar Eliot Berriot 💬

Now return media files with absolute URL

parent e8eaf6db
Pipeline #139 passed with stages
in 2 minutes and 59 seconds
......@@ -313,7 +313,8 @@ REST_FRAMEWORK = {
}
ATOMIC_REQUESTS = False
USE_X_FORWARDED_HOST = True
USE_X_FORWARDED_PORT = True
# Wether we should check user permission before serving audio files (meaning
# return an obfuscated url)
# This require a special configuration on the reverse proxy side
......
......@@ -31,11 +31,20 @@ class ImportBatchSerializer(serializers.ModelSerializer):
model = models.ImportBatch
fields = ('id', 'jobs', 'status', 'creation_date')
class TrackFileSerializer(serializers.ModelSerializer):
path = serializers.SerializerMethodField()
class Meta:
model = models.TrackFile
fields = ('id', 'path', 'duration', 'source', 'filename')
def get_path(self, o):
request = self.context.get('request')
url = o.path
if request:
url = request.build_absolute_uri(url)
return url
class SimpleAlbumSerializer(serializers.ModelSerializer):
......
......@@ -41,6 +41,8 @@ server {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Port $server_port;
proxy_redirect off;
proxy_pass http://funkwhale-api/api/;
}
......
......@@ -63,4 +63,4 @@ services:
- ./docker/nginx/conf.dev:/etc/nginx/nginx.conf
- ./api/funkwhale_api/media:/protected/media
ports:
- "0.0.0.0:6001:80"
- "0.0.0.0:6001:6001"
......@@ -28,7 +28,7 @@ http {
#gzip on;
server {
listen 80;
listen 6001;
charset utf-8;
location /_protected/media {
......@@ -40,6 +40,8 @@ http {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Port $server_port;
proxy_redirect off;
proxy_pass http://api:12081/;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment