Skip to content

Commit e09d383

Browse files
committed
chore: change phcode protocol to phtauri as its interfering with phcode.site and other domains in windows
1 parent ba88ffb commit e09d383

6 files changed

Lines changed: 23 additions & 14 deletions

File tree

src-build/ci-createDistReleaseConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ async function ciCreateDistReleaseConfig() {
7474
console.log("Product name is: ", configJson.package.productName);
7575
configJson.tauri.windows[0].title = configJson.package.productName;
7676
if(os.platform() === 'win32'){
77-
configJson.tauri.windows[0].url = `https://phcode.localhost/v${phoenixVersion}/`;
77+
configJson.tauri.windows[0].url = `https://phtauri.localhost/v${phoenixVersion}/`;
7878
} else {
79-
configJson.tauri.windows[0].url = `phcode://localhost/v${phoenixVersion}/`;
79+
configJson.tauri.windows[0].url = `phtauri://localhost/v${phoenixVersion}/`;
8080
}
8181
console.log("Window Boot url is: ", configJson.tauri.windows[0].url);
8282
configJson.tauri.updater.endpoints = [

src-build/createDistReleaseConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ async function createDistReleaseConfig() {
2222
configJson.build.distDir = '../../phoenix/dist/';
2323
const phoenixVersion = configJson.package.version;
2424
if(os.platform() === 'win32'){
25-
configJson.tauri.windows[0].url = `https://phcode.localhost/v${phoenixVersion}/`;
25+
configJson.tauri.windows[0].url = `https://phtauri.localhost/v${phoenixVersion}/`;
2626
} else {
27-
configJson.tauri.windows[0].url = `phcode://localhost/v${phoenixVersion}/`;
27+
configJson.tauri.windows[0].url = `phtauri://localhost/v${phoenixVersion}/`;
2828
}
2929
console.log("Window Boot url is: ", configJson.tauri.windows[0].url);
3030
console.log("Writing new local config json ", tauriLocalConfigPath);

src-build/createDistTestReleaseConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ async function createDistTestReleaseConfig() {
2424
configJson.build.distDir = '../../phoenix/dist-test/';
2525
const phoenixVersion = configJson.package.version;
2626
if(os.platform() === 'win32'){
27-
configJson.tauri.windows[0].url = `https://phcode.localhost/v${phoenixVersion}/`;
27+
configJson.tauri.windows[0].url = `https://phtauri.localhost/v${phoenixVersion}/`;
2828
} else {
29-
configJson.tauri.windows[0].url = `phcode://localhost/v${phoenixVersion}/`;
29+
configJson.tauri.windows[0].url = `phtauri://localhost/v${phoenixVersion}/`;
3030
}
3131
console.log("Window Boot url is: ", configJson.tauri.windows[0].url);
3232
console.log("Writing new local config json ", tauriLocalConfigPath);

src-build/createSrcReleaseConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ async function createSrcReleaseConfig() {
2222
configJson.build.distDir = '../../phoenix/src/'
2323
const phoenixVersion = configJson.package.version;
2424
if(os.platform() === 'win32'){
25-
configJson.tauri.windows[0].url = `https://phcode.localhost/v${phoenixVersion}/`;
25+
configJson.tauri.windows[0].url = `https://phtauri.localhost/v${phoenixVersion}/`;
2626
} else {
27-
configJson.tauri.windows[0].url = `phcode://localhost/v${phoenixVersion}/`;
27+
configJson.tauri.windows[0].url = `phtauri://localhost/v${phoenixVersion}/`;
2828
}
2929
console.log("Window Boot url is: ", configJson.tauri.windows[0].url);
3030
console.log("Writing new local config json ", tauriLocalConfigPath);

src-tauri/src/main.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,18 @@ fn remove_version_from_url(url: &str) -> String {
120120

121121
fn main() {
122122
tauri::Builder::default()
123-
.register_uri_scheme_protocol("phcode", move |app, request| { // can't use `tauri` because that's already in use
123+
.register_uri_scheme_protocol("phtauri", move |app, request| { // can't use `tauri` because that's already in use
124124
let path = remove_version_from_url(request.uri());
125-
let path = path.strip_prefix("phcode://localhost").unwrap();
125+
let path = path.strip_prefix("phtauri://localhost");
126+
if path.is_none() {
127+
let not_found_response = ResponseBuilder::new()
128+
.status(404)
129+
.mimetype("text/html")
130+
.body("Asset not found".as_bytes().to_vec())
131+
.unwrap();
132+
return Ok(not_found_response);
133+
}
134+
let path = path.unwrap();
126135
let path = percent_encoding::percent_decode(path.as_bytes())
127136
.decode_utf8_lossy()
128137
.to_string();
@@ -143,9 +152,9 @@ fn main() {
143152
let asset = asset_option.unwrap();
144153

145154
#[cfg(windows)]
146-
let window_origin = "https://phcode.localhost";
155+
let window_origin = "https://phtauri.localhost";
147156
#[cfg(not(windows))]
148-
let window_origin = "phcode://localhost";
157+
let window_origin = "phtauri://localhost";
149158

150159
let builder = ResponseBuilder::new()
151160
.header("Access-Control-Allow-Origin", window_origin)

src-tauri/tauri.conf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
"dangerousDisableAssetCspModification": true,
224224
"dangerousRemoteDomainIpcAccess": [
225225
{
226-
"scheme": "phcode",
226+
"scheme": "phtauri",
227227
"domain": "localhost",
228228
"enableTauriAPI": true,
229229
"plugins": [
@@ -266,7 +266,7 @@
266266
},
267267
{
268268
"scheme": "https",
269-
"domain": "phcode.localhost",
269+
"domain": "phtauri.localhost",
270270
"enableTauriAPI": true,
271271
"plugins": [
272272
"fs-extra"

0 commit comments

Comments
 (0)