How to create specific URIs for users in FIREBASE WEB javascript

后端 未结 1 1878
花落未央
花落未央 2021-01-28 02:07

I have a firebase project developed in javscript html and css that works like a social network, i have users in my database and these users have profile information to show.

相关标签:
1条回答
  • 2021-01-28 02:20

    What you're describing is a single-page application, where a single HTML+JavaScript page is handling many URLS - dynamically generating the content.

    You'll need to implement multiple steps:

    1. Configure Firebase Hosting to direct multiple incoming URLs to the same HTML page. This is done with a rewrite rule in your firebase.json file, such as:

      "rewrites": [ {
        "source": "**",
        "destination": "/index.html"
      } ]
      
    2. Now the JavaScript of your index.html page can inspect the URL in window.location.href, extract the user name from it, and then serve the correct content for that user.

    0 讨论(0)
提交回复
热议问题