我正在嘗試將呼叫mywebsite.com/poly/1的人重定向到相應的.png影像,但它不起作用。
我嘗試過使用 Glob:
"rewrites": [
{
"source": "/poly/:tokenId",
"destination": "/images/:tokenId/img.png",
"type": 301,
"headers": [ {
"key": "Access-Control-Allow-Origin",
"value": "*"
}]
}
]
正則運算式:
"rewrites": [
{
"regex": "/poly/(\\d )",
"destination": "/images/:1/img.png",
"type": 301,
"headers": [ {
"key": "Access-Control-Allow-Origin",
"value": "*"
}]
}
]
我總是得到一個 404,但如果目的地是靜態的,它就可以作業,例如:
"destination": "/images/1/img.png",
我已經使用firebase serve.
有任何想法嗎?
uj5u.com熱心網友回復:
您正在混合rewrites和redirects的語法。
// rewrites
"hosting": {
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ]
}
// redirects
"hosting": {
"redirects": [ {
"source": "/foo",
"destination": "/bar",
"type": 301
} ]
}
重寫匹配源檔案并提供目標檔案。它們不支持 URL 段。
重定向匹配源并告訴瀏覽器使用目標路徑。它們確實支持 URL 段。
如果您不介意目標路徑可用,則可以使用重寫。您可以將檔案上傳到 Firebase 存盤并通過函式代理檔案,但這并不理想。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/421179.html
標籤:
