Coder Social home page Coder Social logo

Make build independent of base url about branle HOT 6 OPEN

fiatjaf avatar fiatjaf commented on August 16, 2024
Make build independent of base url

from branle.

Comments (6)

fiatjaf avatar fiatjaf commented on August 16, 2024 1

It is clear now.

from branle.

Giszmo avatar Giszmo commented on August 16, 2024

c04c4d7#diff-1d7ff4f413e8862d32dfe18796e76517d15cdb33a09e11ce2dc65c07c11df1f6R48 appears to have introduced this issue.

Edit: commenting the line out doesn't help. It still adds absolute paths to the minified result.

from branle.

fiatjaf avatar fiatjaf commented on August 16, 2024

I deploy by dropping the ./dist/spa/ directory on a webserver and it works.

The problem is that you'll need to rewrite all URLs to serve the base index.html, otherwise linking directly to a profile or event will get you a 404. You can do that kind of rewrite in nginx or Caddy very easily, or on Netlify or these other static website servers.

from branle.

Giszmo avatar Giszmo commented on August 16, 2024

Would it be easy to restore the arcbtc/nostr behavior so I can try to then fix what you describe in other ways? The JS should be trivially able to figure out its base path and use it dynamically from there. "do rewrite in Caddy or nginx" is just adding complexity that would be nice to strip away so more people drop it onto their servers/blogs/websites.

from branle.

fiatjaf avatar fiatjaf commented on August 16, 2024

I don't understand what you're saying. I don't understand the error you're facing. I don't understand what is the behavior you want me to restore. I don't know how arcbtc/nostr worked.

I'm telling you it works by just deploying the files to a static file server. The nginx rewrite part is a detail and not necessary.

If it is not working to just deploy the files, please tell me what is not working. I don't understand the logs you posted on the first message. If I had to guess I would say they are caused by a caching issue.

from branle.

Giszmo avatar Giszmo commented on August 16, 2024

I have a website, so obviously that website has an index.html in its root folder that gets used if you navigate to website.com/. I now want to deploy nostr to website.com/nostr/ but the generated index.html includes /js/532.9c3f5fab.js and not a relative js/532.9c3f5fab.js or a magically correct absolute /nostr/js/532.9c3f5fab.js which obviously points to a file that does not exist. If that is not clear or not how it works on your end, I'll reproduce it.

Edit: You said it's clear but here is anyway what I did:

branle(master)$ podman run --rm --volume $PWD:/t -it node bash
root@de15c894139f:/# cd /t
root@de15c894139f:/t# yarn
root@de15c894139f:/t# 
exit
branle(master)$ cp -r dist/spa/ ../website.com/assets/branle

Now, surfing to http://localhost:4000/assets/branle/ the dev console in my browser says:

22:17:33.254 Loading failed for the <script> with source “http://localhost:4000/js/app.8cc937ea.js”. [branle:1:1](http://localhost:4000/assets/branle/)
22:17:33.254 Loading failed for the <script> with source “http://localhost:4000/js/vendor.0677838b.js”. [branle:1:1](http://localhost:4000/assets/branle/)

With arcbtc/nostr it just worked.

from branle.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.