Cuando alguien visita mi directorio raíz "https://example.com/", quiero mostrar un archivo .html normal. (index.html) ¿Cómo puedo hacer eso con next.js?
Investigué y edité mi archivo de configuración de esta manera,
/** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, rewrites: async () => { return [ { source: "/public/myfile.html", destination: "/pages/api/myfile.js", }, ]; }, };/pages/api/miArchivo.js
import fs from "fs"; const filename = "/index.html"; export default async function api(req, res) { res.setHeader("Content-Type", "text/html; charset=utf-8"); res.write(await fs.readFileSync(filename, "utf-8")); res.end(); } module.exports = nextConfig;pero este archivo de configuración muestra mi página .html justo cuando llego a esta URL: https://example.com/index.html
rewrites: async () => [ { source: "/", destination: "/index.html", }, ],agregué esto en mi archivo next.config.js (en el objeto nextConfig)
Tengo un archivo index.html en mi directorio /public.