Parametrize configurations¡
This commit is contained in:
@@ -5,7 +5,20 @@ server {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location = /taller {
|
||||
return 301 /taller/;
|
||||
}
|
||||
|
||||
location /taller/api/ {
|
||||
proxy_pass http://backend:8000/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
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;
|
||||
}
|
||||
|
||||
location /taller/ {
|
||||
try_files $uri $uri/ /index.html;
|
||||
try_files $uri $uri/ /taller/index.html;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,9 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
|
||||
const baseUrl = import.meta.env.BASE_URL || '/';
|
||||
const defaultApiBase = `${baseUrl.replace(/\/$/, '')}/api`;
|
||||
const rawApiBase = import.meta.env.VITE_API_BASE || defaultApiBase;
|
||||
|
||||
export const API_BASE = rawApiBase.replace(/\/$/, '');
|
||||
export const ENABLE_POLLING = import.meta.env.MODE !== 'test';
|
||||
|
||||
@@ -1,14 +1,34 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
||||
|
||||
export default defineConfig({
|
||||
base: '/taller/',
|
||||
plugins: [svelte()],
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
globals: true,
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
},
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), 'VITE_');
|
||||
const basePath = '/taller/';
|
||||
const defaultApiBase = `${basePath.replace(/\/$/, '')}/api`;
|
||||
const apiBase = (env.VITE_API_BASE || defaultApiBase).replace(/\/$/, '');
|
||||
const apiProxyPath = apiBase.startsWith('http') ? null : apiBase;
|
||||
|
||||
return {
|
||||
base: basePath,
|
||||
plugins: [svelte()],
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
globals: true,
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
proxy: apiProxyPath
|
||||
? {
|
||||
[apiProxyPath]: {
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) =>
|
||||
path.startsWith(apiProxyPath)
|
||||
? path.slice(apiProxyPath.length) || '/'
|
||||
: path,
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user