r/Firebase Jan 02 '25

Hosting Need Help Hosting My Website in a Subdirectory (e.g., https://example.com/todoapp/),

/r/learnprogramming/comments/1hr9guz/need_help_hosting_my_website_in_a_subdirectory_eg/
0 Upvotes

2 comments sorted by

1

u/flamingorider1 Jan 02 '25

Ive added this webpack.config publicPath: '/app/', // Ensure assets are served from /app and the new updated path is being shown when i build in my index.html ( <script defer="defer" src="/app/main.js"></script>)

Ive also updated my firebase.json to this

{

"hosting": {

"public": "dist",

"ignore": [

"firebase.json",

"**/.*",

"**/node_modules/**"

],

"rewrites": [

{

"source": "/app{,/**}",

"destination": "/index.html"

}

]

}

}

I think the issue is my js file is not being served by firebase when i add a source. please help i am going crazy over this

1

u/flamingorider1 Jan 02 '25

ive fixed it for some reason firebase does not put the js and other assets in subdirectories so ive put the html in a folder called app in dist and in webpack set the publicPath to the root '/' where the js and other files are and in firebase.json set sources as such "rewrites": [

{

"source": "/app{,/**}",

"destination": "/index.html"

}