nextJs 跨域访问接口数据

567 阅读1分钟

在next.config.js中使用rewrites解决跨域 async rewrites() { return [ { source: '/api/:path*', destination: `xxx.com/api/:path\*… } ] } 接口调用的时候使用 '/api/...'这种格式, 当然也可以使用express,网上教程很多