asticode / go-astilectron

Build cross platform GUI apps with GO and HTML/JS/CSS (powered by Electron)
MIT License
4.9k stars 344 forks source link

Html absolute paths not working and this also makes React apps not working #298

Closed tommi-hack closed 3 years ago

tommi-hack commented 3 years ago

Simple example. I have index.html including tag in example below, and "a.png" in the same folder. Here "a.png" is not found because it has slash in the beginning of path. Without the slash it works.

  <img src="/a.png">

This would not be a problem for manually written html but React toolchain makes all includes and paths absolute and it makes impossible to use React with go-astilectron.

Proposal: Go-astilectron could internally remove the slash from the begining of path.

asticode commented 3 years ago

@tommi-hack check out this issue it may fix your problem

tommi-hack commented 3 years ago

@asticode this is awesome, thank you so much. I did spend quite a lot of time trying to get this working. I think it would be super beneficial to add this information to Readme. Maybe something like that:

All paths in html / javascript must be relative, otherwise the files will not be found. To make this happen in React for example, you just need to set the homepage property of your package json to "./".

{ "homepage": "./" }

asticode commented 3 years ago

I think this would be a good idea indeed. Do you feel like making a PR for this?

tommi-hack commented 3 years ago

I would gladly do a PR but now sure how. It seems I can't push new branch here. I haven't contributed to public repositories before. From some sources I read that I should fork this repository before making my changes but they are a bit contradicting. If you have a good manual to point how can one submit a PR then it would be nice.

asticode commented 3 years ago

Here are a few links that will help you:

Basically you have to fork the project, create a new branch on your local copy, make the proper changes in the code for the PR, push your branch, and create a PR from your branch in github.

tommi-hack commented 3 years ago

PR created, thank you for the hints!