]> git.parisson.com Git - teleforma.git/commitdiff
Better handling interoperability between webpack dev server and docker
authortest test <yoanl@pilotsystems.net>
Thu, 15 Jul 2021 15:31:28 +0000 (17:31 +0200)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 15 Jul 2021 15:31:28 +0000 (17:31 +0200)
teleforma/templatetags/webpack.py

index b3e947a0ab5cdbca9f1944d0406e9601d6dc7ad1..d5f8cdfe17394cce736daa3f1d25a74327903a0d 100644 (file)
@@ -20,13 +20,15 @@ def webpack(bundle):
             WEBPACK_APP_URL = '{}{}'.format(settings.WEBPACK_DEV_SERVER_URL, bundle)
             request = requests.get(WEBPACK_APP_URL)
             if request.status_code == 200:
-                url = WEBPACK_APP_URL
+                # host.docker.internal is only available in the context of the container, not in the browser
+                url = WEBPACK_APP_URL.replace('host.docker.internal', 'localhost')
                 if is_css:
                     url = None
         except requests.ConnectionError:
             pass
 
-    url += '?v=' + teleforma.__version__
+    if url:
+        url += '?v=' + teleforma.__version__
 
     return {
         'is_css': is_css,