From 34fdcc10705e66ef3d84b6223c3c81926ceed69d Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Wed, 28 Oct 2020 14:52:25 +0100
Subject: [PATCH] fix: nginx conf + build

---
 angular.json   |  2 +-
 nginx/dev.conf | 34 ++++++++++++++++++++++++----------
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/angular.json b/angular.json
index 1388d5261..20abea0c5 100644
--- a/angular.json
+++ b/angular.json
@@ -61,7 +61,7 @@
               "namedChunks": false,
               "extractLicenses": true,
               "vendorChunk": false,
-              "buildOptimizer": true,
+              "buildOptimizer": false,
               "budgets": [
                 {
                   "type": "initial",
diff --git a/nginx/dev.conf b/nginx/dev.conf
index 0ec8e46c4..753267181 100644
--- a/nginx/dev.conf
+++ b/nginx/dev.conf
@@ -1,23 +1,37 @@
+
 server {
   listen 8080 default_server;
 
-  root /usr/share/nginx/html/;
+  root /usr/share/nginx/html;
 
   location / {
     # First attempt to serve request as file, then
     # as directory, then fall back to displaying a 404.
     try_files $uri $uri/ /index.html;
-    sub_filter '<html lang="en">' '<html lang="fr">';
   }
 
-      # Rule serving the en build
-    location /en {
-        try_files $uri$args /en/index.html;
-    }
+  location /api {
+    rewrite ^/api/(.*) /$1 break;
+    proxy_pass http://json-server:3000/api;
+  }
+  
+  # Public api redirect
+  location /base-adresse/base-adresse-nationale/streets {
+    proxy_pass https://passerelle.formulaireextranet.grandlyon.com/base-adresse/base-adresse-nationale/streets;
+  }
+
+  location /geocoding/photon/api {
+    proxy_pass https://download.data.grandlyon.com/geocoding/photon/api;
+  }
 
-    # redirecting the /fr url to the new location of the fr build
-    location ~ ^/fr(.*)$ {
-        return 301 $scheme://$http_host$1$is_args$args;
-    }
+   location /reverse {
+    proxy_pass https://api-adresse.data.gouv.fr/reverse;
+  }
+
+
+  # REALLY important for JavaScript modules (type="module") to work as expected!!!
+  location ~ \.js {
+    add_header  Content-Type   text/javascript;
+  }
 
 }
-- 
GitLab