stacker.news/next.config.js

94 lines
2.1 KiB
JavaScript
Raw Normal View History

2021-07-15 20:49:13 +00:00
const { withPlausibleProxy } = require('next-plausible')
2022-01-21 18:24:03 +00:00
const isProd = process.env.NODE_ENV === 'production'
const corsHeaders = [
{
key: 'Access-Control-Allow-Origin',
2022-07-10 22:46:22 +00:00
value: '*'
2022-01-21 18:24:03 +00:00
},
{
key: 'Access-Control-Allow-Methods',
2022-07-10 22:46:22 +00:00
value: 'GET, HEAD, OPTIONS'
2022-01-21 18:24:03 +00:00
}
]
2021-07-15 20:49:13 +00:00
module.exports = withPlausibleProxy()({
2021-10-07 03:26:57 +00:00
compress: false,
2021-10-25 19:49:46 +00:00
experimental: {
scrollRestoration: true
},
2021-10-20 19:57:11 +00:00
generateBuildId: process.env.NODE_ENV === 'development'
? undefined
: async () => {
2022-01-21 18:24:03 +00:00
// use the app version which eb doesn't otherwise give us
// as the build id
const { RuntimeSources } = require('/opt/elasticbeanstalk/deployment/app_version_manifest.json') // eslint-disable-line
2021-10-20 19:57:11 +00:00
return Object.keys(RuntimeSources['stacker.news'])[0]
},
2022-01-21 18:24:03 +00:00
// Use the CDN in production and localhost for development.
2022-01-21 18:43:57 +00:00
assetPrefix: isProd ? 'https://a.stacker.news' : '',
2022-01-21 18:24:03 +00:00
async headers () {
return [
{
source: '/_next/:asset*',
headers: corsHeaders
2022-01-21 18:58:21 +00:00
},
{
source: '/Lightningvolt-xoqm.ttf',
headers: [
...corsHeaders,
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable'
}
]
2022-01-21 18:24:03 +00:00
}
]
},
2021-07-15 23:06:21 +00:00
async rewrites () {
return [
{
source: '/faq',
destination: '/items/349'
2021-09-02 17:49:17 +00:00
},
{
source: '/story',
destination: '/items/1620'
2021-10-07 18:37:59 +00:00
},
2022-10-04 17:19:15 +00:00
{
source: '/privacy',
destination: '/items/76894'
},
2022-10-10 21:58:50 +00:00
{
source: '/changes',
destination: '/items/78763'
},
2022-10-23 15:43:39 +00:00
{
source: '/guide',
destination: '/items/81862'
},
2021-10-07 18:37:59 +00:00
{
source: '/.well-known/lnurlp/:username',
destination: '/api/lnurlp/:username'
2022-02-14 18:49:06 +00:00
},
{
2022-02-17 17:23:43 +00:00
source: '/~:sub',
destination: '/~/:sub'
},
{
source: '/~:sub/:slug*',
destination: '/~/:sub/:slug*'
2021-07-15 23:06:21 +00:00
}
]
},
async redirects () {
return [
{
source: '/statistics',
destination: '/satistics?inc=invoice,withdrawal',
permanent: true
}
]
2021-07-15 23:06:21 +00:00
}
2021-07-15 20:49:13 +00:00
})