From 9ab3afa47feb21dbfe6db5781cb369ebf71540a4 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Thu, 9 Jan 2020 16:12:17 +0100
Subject: [PATCH] Fixed broken urls in manifest.json

---
 api/funkwhale_api/instance/views.py | 2 ++
 api/tests/instance/test_views.py    | 3 +++
 front/vue.config.js                 | 7 ++++---
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/api/funkwhale_api/instance/views.py b/api/funkwhale_api/instance/views.py
index 0c88bd45..7117d1a1 100644
--- a/api/funkwhale_api/instance/views.py
+++ b/api/funkwhale_api/instance/views.py
@@ -10,6 +10,7 @@ from rest_framework.response import Response
 
 from funkwhale_api.common import middleware
 from funkwhale_api.common import preferences
+from funkwhale_api.federation import utils as federation_utils
 from funkwhale_api.users.oauth import permissions as oauth_permissions
 
 from . import nodeinfo
@@ -57,6 +58,7 @@ class SpaManifest(views.APIView):
         )
         parsed_manifest = json.loads(existing_manifest)
         parsed_manifest["short_name"] = settings.APP_NAME
+        parsed_manifest["start_url"] = federation_utils.full_url("/")
         instance_name = preferences.get("instance__name")
         if instance_name:
             parsed_manifest["short_name"] = instance_name
diff --git a/api/tests/instance/test_views.py b/api/tests/instance/test_views.py
index 1ef122ea..4bc9c296 100644
--- a/api/tests/instance/test_views.py
+++ b/api/tests/instance/test_views.py
@@ -2,6 +2,8 @@ import json
 
 from django.urls import reverse
 
+from funkwhale_api.federation import utils as federation_utils
+
 
 def test_nodeinfo_endpoint(db, api_client, mocker):
     payload = {"test": "test"}
@@ -54,6 +56,7 @@ def test_manifest_endpoint(api_client, mocker, preferences, tmp_path, settings):
         "name": "Test pod",
         "short_name": "Test pod",
         "description": "Test description",
+        "start_url": federation_utils.full_url("/"),
     }
     manifest.write_bytes(json.dumps(base_payload).encode())
 
diff --git a/front/vue.config.js b/front/vue.config.js
index 8ee1b27e..9fcae743 100644
--- a/front/vue.config.js
+++ b/front/vue.config.js
@@ -1,3 +1,4 @@
+const baseUrl = process.env.BASE_URL || '/front/'
 
 const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
 const webpack = require('webpack');
@@ -30,7 +31,7 @@ plugins.push(
   }),
 )
 module.exports = {
-  baseUrl: process.env.BASE_URL || '/front/',
+  baseUrl: baseUrl,
   productionSourceMap: false,
   // Add settings for manifest file
   pwa: {
@@ -48,11 +49,11 @@ module.exports = {
       categories: ["music"],
       icons: [
         {
-          'src': 'favicon.png',
+          'src': baseUrl + 'favicon.png',
           'sizes': '192x192',
           'type': 'image/png'
         },        {
-          'src': 'favicon.png',
+          'src': baseUrl + 'favicon.png',
           'sizes': '512x512',
           'type': 'image/png'
         },
-- 
GitLab