Skip to content

Commit 8ab5f7a

Browse files
committed
fix sitemap route
1 parent a6b0272 commit 8ab5f7a

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite --force",
8-
"build": "vite build",
8+
"build": "node scripts/fetch-sitemap.js && vite build",
99
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
1010
"preview": "vite preview"
1111
},

scripts/fetch-sitemap.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import fs from "fs";
2+
import fetch from "node-fetch";
3+
4+
async function main() {
5+
const res = await fetch("https://news-api-ko52.onrender.com/api/v1/sitemap.xml");
6+
const xml = await res.text();
7+
fs.writeFileSync("./public/sitemap.xml", xml);
8+
console.log("Sitemap generated!");
9+
}
10+
11+
main();

vercel.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
"destination": "https://api64.ipify.org?format=json"
66
},
77
{ "source": "/api", "destination": "https://news-api-fai7.onrender.com" },
8-
{ "source": "/(.*)", "destination": "/" },
9-
{
10-
"source": "/sitemap.xml",
11-
"destination": "https://news-api-k052.onrender.com/api/v1/sitemap.xml"
12-
}
8+
{ "source": "/(.*)", "destination": "/" }
139
]
1410
}

vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default defineConfig({
2121
target: "https://api64.ipify.org?format=json",
2222
changeOrigin: true,
2323
rewrite: (path) => path.replace(/^\/ipify/, ""),
24-
},
24+
}
2525
},
2626
},
2727
});

0 commit comments

Comments
 (0)