javascript
复制代码
const express = require('express');
const cors = require('cors'); // 引入 cors 中间件
const app = express();
const port = 3000;
app.use(cors()); // 使用 cors 中间件
const catList = [
{
image: 'https://1317036699.vod2.myqcloud.com/8af1bb6fvodcq1317036699/d2b016581253642700822735154/As9K0OL6r7AA.jpg',
title: '猫1',
originalPrice: 9999,
favourPrice: 8888,
tip: '自营'
},
// ... 其他猫的数据
];
app.get('/api/cats', (req, res) => {
res.json(catList);
});
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});