🚧 move to new config based env

This commit is contained in:
Philipp Dormann 2020-12-20 18:07:58 +01:00
parent 8ef0b21819
commit 2cdd1cd961
5 changed files with 19 additions and 16 deletions

2
.gitignore vendored
View File

@ -3,4 +3,4 @@
node_modules node_modules
dist dist
dist-ssr dist-ssr
public/env.js

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.0.2/dist/tailwind.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.0.2/dist/tailwind.min.css">
</head> </head>
<body> <body>
<script type="module" src="/src/index.js"></script> <script src="/env.js"></script>
<script defer type="module" src="/src/index.js"></script>
</body> </body>
</html> </html>

View File

@ -1,12 +1,9 @@
# http { events{}
http {
include mime.types; include mime.types;
# sendfile on; sendfile on;
server { server {
root /usr/share/nginx/html; root /usr/share/nginx/html;
location / {
add_header "Set-Cookie" '${APP_CONF}';
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires 1y; expires 1y;
add_header Pragma public; add_header Pragma public;
@ -27,4 +24,4 @@
gzip_http_version 1.1; gzip_http_version 1.1;
gzip_types application/javascript application/rss+xml application/vnd.ms-fontobject application/x-font application/x-font-opentype application/x-font-otf application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/opentype font/otf font/ttf image/svg+xml image/x-icon text/css text/javascript text/plain text/xml; gzip_types application/javascript application/rss+xml application/vnd.ms-fontobject application/x-font application/x-font-opentype application/x-font-otf application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/opentype font/otf font/ttf image/svg+xml image/x-icon text/css text/javascript text/plain text/xml;
} }
# } }

6
public/env.sample.js Normal file
View File

@ -0,0 +1,6 @@
const config = {
baseurl: 'http://localhost:4010',
// optional params ⏬
fallback_username: 'demo',
fallback_password: 'demo'
};

View File

@ -1,7 +1,6 @@
<script> <script>
import store from "../store.js"; import store from "../store.js";
import { _ } from "svelte-i18n"; import { _ } from "svelte-i18n";
import { config } from "../dev.env";
store.init(); store.init();
import { push, pop, replace } from "svelte-spa-router"; import { push, pop, replace } from "svelte-spa-router";
// //
@ -24,12 +23,12 @@
}).showToast(); }).showToast();
let username = usersUsername; let username = usersUsername;
let password = usersPassword; let password = usersPassword;
if (username.length == 0) { // if (usersUsername.length == 0) {
username = config.default_username || "demo"; username = config.fallback_username || "demo";
} // }
if (password.length == 0) { // if (usersPassword.length == 0) {
password = config.default_password || "demo"; password = config.fallback_password || "demo";
} // }
AuthService.authControllerLogin({ AuthService.authControllerLogin({
username, username,
password, password,