Skip to content

Commit 7d0fabc

Browse files
feat: remove APP_HOST env var necessity (#111)
1 parent 12e1422 commit 7d0fabc

4 files changed

Lines changed: 13 additions & 20 deletions

File tree

.github/workflows/check-pr.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
name: Check
2-
env:
3-
APP_HOST: ${{ secrets.APP_HOST }}
42
on:
53
pull_request:
64
branches:

.github/workflows/github-actions.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Build & Deploy
22
env:
33
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
44
GCP_BUCKET: ${{ secrets.GCP_BUCKET }}
5-
APP_HOST: ${{ secrets.APP_HOST }}
65
on:
76
push:
87
branches:

README.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,8 @@ Read more about features and motivation here: https://tbt.qkation.com/projects/c
5252

5353
0. Install WebAssembly target: `rustup target add wasm32-unknown-unknown`.
5454
1. Install [`trunk`](https://github.com/thedodd/trunk). [Additional guide](https://yew.rs/docs/next/getting-started/introduction#install-trunk).
55-
2. Set up `APP_HOST` environment variable:
56-
```bash
57-
# Windows
58-
set APP_HOST=<url>
59-
# Linux
60-
export APP_HOST=<url>
61-
# example:
62-
# export APP_HOST=https://crypto-helper.qkation.com
63-
```
64-
This env variable is used for the URL generation when you click the *share by URL* button.
65-
66-
3. Run `trunk serve` in your terminal.
67-
4. Go to http://127.0.0.1:8080 in your browser.
55+
2. Run `trunk serve` in your terminal.
56+
3. Go to http://127.0.0.1:8080 in your browser.
6857

6958
### Meta
7059

src/url_query_params.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
use serde::{Deserialize, Serialize};
2+
use web_sys::window;
23

34
use crate::crypto_helper::Algorithm;
45
use crate::serde::{deserialize_bytes, serialize_bytes};
56

6-
const APP_HOST: &str = env!("APP_HOST");
7+
fn origin() -> String {
8+
window()
9+
.expect("windows object must present")
10+
.location()
11+
.origin()
12+
.expect("page must have the origin string")
13+
}
714

815
pub fn generate_crypto_helper_link(algorithm: &Algorithm) -> String {
9-
let mut link = APP_HOST.to_string();
16+
let mut link = origin();
1017

1118
link.push_str("/crypto-helper/?");
1219
link.push_str(&serde_qs::to_string(algorithm).unwrap());
@@ -20,7 +27,7 @@ pub struct Jwt {
2027
}
2128

2229
pub fn generate_jwt_link(jwt: String) -> String {
23-
let mut link = APP_HOST.to_string();
30+
let mut link = origin();
2431

2532
link.push_str("/jwt/?");
2633
link.push_str(&serde_qs::to_string(&Jwt { jwt }).unwrap());
@@ -35,7 +42,7 @@ pub struct Asn1 {
3542
}
3643

3744
pub fn generate_asn1_link(asn1: Vec<u8>) -> String {
38-
let mut link = APP_HOST.to_string();
45+
let mut link = origin();
3946

4047
link.push_str("/asn1/?");
4148
link.push_str(&serde_qs::to_string(&Asn1 { asn1 }).unwrap());

0 commit comments

Comments
 (0)