Asked By: Anonymous
So, I want to add a ads.js to my site, but the example from Next github is not so clear. Anyone knows how to do it?
Here’s the next example with robots and a sitemap:
https://github.com/zeit/next.js/tree/canary/examples/with-sitemap-and-robots-express-server
Thank you!
Solution
Answered By: Anonymous
Depends on where is this file needs to go you can do one of this options.
- if not matter, just drop it inside the
/static
folder and call it whitgo.to/static/ads.txt
- drop it inside
/static
folder and add this script to your custom server to handle this new path/ads.txt
in the way to make accessible withgo.to/ads.txt
server.get('/ads.txt', (req, res) => {
const filePath = join(__dirname, 'static/ads.txt')
app.serveStatic(req, res, filePath)
})
server.get('*', (req, res) => handle(req, res))
this solution work in the express server.