-
Notifications
You must be signed in to change notification settings - Fork 57
HTTPS required when server not on localhost #3
Comments
Check your $HOST environment variable |
I might change the environment variable being read due to conflicts with pre-existing variables |
Also open up |
The answer is most likely yes unless you're running it on localhost. They use https by default for the websocket |
Ok, I'll configure the https. I have two more questions:
|
Trying to get this to work locally:
The handlers are running and I can interact with them via cURL HTTP requests, but my Obsidian app on macOS doesn't seem to be working. Happy to help with submitting PRs to get this working and developing this further (have been very annoyed by iCloud syncing not working well with Obsidian). |
This comment was marked as resolved.
This comment was marked as resolved.
When running on localhost, there is no need to export HOST. |
To debug, you can open up the electron developer tools and do |
Yes. |
By default, if you don't configure it: var Host = "localhost:3000/ws" |
That is the full nginx config. My SSL/TLS is being handled by Cloudflare |
If you're running on localhost, there is no need for nginx ofc |
Another possible issue: There has been a lot of breaking changes over the past few days & hours as I add new features. You might need to delete the db files and restart (and sign up again) if you've pulled new versions |
I don't see any connections to /ws or /. |
Edit: Sorry. Light mode is killing me. |
sorry.... I did not use dark mode... |
|
Ah here it is. It's using wss:// instead of ws://. It expects HTTPS when the endpoint is anything other than localhost or 127.0.0.1 |
what should I do to make it work? |
Use something like certbot to get an TLS certificate. |
I just use it in my inner network at home... could TLS be skipped? |
Here is the bit of code in the Obsidian app that manages this: (t.prototype.getHost = function () {
var e = this.host || "127.0.0.1:3003";
return e.startsWith("127.0.0.1") || e.startsWith("localhost")
? "ws://" + e
: "wss://" + e;
}), Another solution is to update the plugin to also intercept wss/ws requests but that'll take a while. (I have 0 experience in JS) |
It's hard coded into the app. For now, no |
https://certbot.eff.org/instructions?ws=nginx&os=ubuntufocal&tab=standard I'm trying by this instruction now... |
if (this.settings.SyncAPI.startsWith("http://")) {
// Websocket intercept
const originalWebSocket = window.WebSocket;
// Override the WebSocket constructor
window.WebSocket = class CustomWebSocket extends originalWebSocket {
constructor(url: string, protocols?: string | string[]) {
const newUrl = url.replace("wss://", "ws://");
super(newUrl, protocols);
}
};
} This might work in the plugin. Testing |
Issue: app.js loads before plugins. They make it a constant |
still thanks for ur effort... |
Note to whomever comes across this issue again: Cannot fix. HTTPS is required when not localhost |
Thank you so much for this. What I've done:
I see requests being made to the Do I need to manually turn on Obsidian Sync from somewhere within the application's preference settings? UPDATE: ah ok my bad, I need to turn on Sync within the Core Plugins page. will tinker further. UPDATE 2: It's working now! What I did
Thanks again! |
it's possible to use HTTP. you just have to hack the |
@CzBiX Thank you! I don't actually know JavaScript, could you explain how you found this?
I thought of the same but was unable to implement it because I couldn't find where the getHost function was |
I'm getting |
@acheong08 It's not easy to explain, but in short, this is all that you can get with reverse engineering.
This is a non-public API that is not exposed, you have to use |
This worked. Thank you! |
CC @wangweitung You can update from https://github.com/acheong08/rev-obsidian-sync-plugin/releases/tag/1.0.3 Perhaps for the plugin, we can switch to using @CzBiX's repository considering they're much more experienced with JS |
thank you both , it's happy to hear this good news! |
I set it up by referring to your readme. However it does not open the synchronization process properly. I don't know if I need to apply https certificate? The specific error message is as follows:
The text was updated successfully, but these errors were encountered: