Unexpected trailing slash behaviour with Firebase hosting -
i'm seeing unexpected behaviour (at least per me) trailing slashes on firebase hosting. expect firebase serve urls trailing slash (except actual files present in hosting directory). set trailingslash
true
in firebase.json.
this resulted in:
example.com redirect example.com/index.html/ example.com/js/script.js redirect example.com/js/script.js/ example.com/images/image.png redirect example.com/images/image.png/
the expected behaviour be:
example.com redirect example.com/ example.com/js/script.js served without redirect example.com/images/image.png served without redirect
the addition of trailing slash actual file urls makes browser/server think script.js
directory instead of file , results in 404. addition of index.html root isn't elegant.
expecting cleanurls
trick set cleanurls
true
along trailingslash
, site goes endless redirect loop , fails load. how can stop firebase adding "index.html" @ root , trailing slash actual js or image assets?
edit:
as requested frank here's firebase.json i'm using:
{ "firebase" : "example", "public" : "public", "cleanurls" : false, "trailingslash" : true, "ignore" : [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [{ "source" : "**", "destination" : "/index.html" }], "headers": [{ "source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)", "headers" : [{ "key" : "access-control-allow-origin", "value" : "*" }] }, { "source" : "**/*.@(jpg|jpeg|gif|png)", "headers" : [{ "key" : "cache-control", "value" : "max-age=600" }] }, { "source" : "**/*.@(html|js)", "headers" : [{ "key" : "cache-control", "value" : "max-age=300" }] }] }
p.s.: have tried setting both trailingslash
, cleanurls
true
, tried setting these true/false
individually.
as question, if want invoke command "rewrites", server can execute "rewirtes" command when cannot find index.html in root directory.
the solution one: put index.html in root directory under "public" folder. switch public folder , deploy server.
the solution two: put index.html under folder can named whatever. use json format: "rewrites": [{ "source" : "**", "destination" : "/foldername/index.html" }],
cannot put index.html under root folder.
the solution three: create root folder, put js/css/img/ folders , index.html under root folder. deploy server json file this.
{ "firebase": "you app name", "public": ".", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ],
Comments
Post a Comment