■ ■ ■ ■ ■ ■ ■
packages/web/src/server.tsx
| skipped 7 lines |
8 | 8 | | import { store } from './store'; |
9 | 9 | | import { App } from './components/App'; |
10 | 10 | | import path from 'path'; |
11 | | - | import { readFileSync } from 'fs'; |
| 11 | + | import { readFileSync, readFile } from 'fs'; |
12 | 12 | | |
13 | 13 | | const app = express(); |
14 | 14 | | const layout = readFileSync(path.resolve(__dirname, 'static', 'index.html'), { encoding: 'utf-8' }); |
15 | 15 | | |
16 | 16 | | app.use('/static', express.static(path.join(__dirname, 'static'))); |
| 17 | + | app.get('/robots.txt', (_, res) => |
| 18 | + | readFile(path.join(__dirname, '/robots.txt'), { encoding: 'utf-8' }, (err, data) => { |
| 19 | + | if (!err) { |
| 20 | + | res.send(data); |
| 21 | + | } else { |
| 22 | + | res.status(404); |
| 23 | + | res.send(null); |
| 24 | + | } |
| 25 | + | }) |
| 26 | + | ); |
17 | 27 | | |
18 | 28 | | app.get('*', (req, res) => { |
19 | 29 | | const html = ReactDOMServer.renderToString( |
| skipped 20 lines |