prep for CDN by setting headers
This commit is contained in:
parent
faaa30ac50
commit
a9fb5c8fe6
@ -1,5 +1,17 @@
|
|||||||
const { withPlausibleProxy } = require('next-plausible')
|
const { withPlausibleProxy } = require('next-plausible')
|
||||||
|
|
||||||
|
const isProd = process.env.NODE_ENV === 'production'
|
||||||
|
const corsHeaders = [
|
||||||
|
{
|
||||||
|
key: 'Access-Control-Allow-Origin',
|
||||||
|
value: isProd ? 'https://stacker.news' : 'http://localhost:3000'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'Access-Control-Allow-Methods',
|
||||||
|
value: 'GET, PUT, POST, DELETE, HEAD, OPTIONS'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
module.exports = withPlausibleProxy()({
|
module.exports = withPlausibleProxy()({
|
||||||
compress: false,
|
compress: false,
|
||||||
experimental: {
|
experimental: {
|
||||||
@ -8,11 +20,21 @@ module.exports = withPlausibleProxy()({
|
|||||||
generateBuildId: process.env.NODE_ENV === 'development'
|
generateBuildId: process.env.NODE_ENV === 'development'
|
||||||
? undefined
|
? undefined
|
||||||
: async () => {
|
: async () => {
|
||||||
// use the app version which eb doesn't otherwise give us
|
// use the app version which eb doesn't otherwise give us
|
||||||
// as the build id
|
// as the build id
|
||||||
const { RuntimeSources } = require('/opt/elasticbeanstalk/deployment/app_version_manifest.json') // eslint-disable-line
|
const { RuntimeSources } = require('/opt/elasticbeanstalk/deployment/app_version_manifest.json') // eslint-disable-line
|
||||||
return Object.keys(RuntimeSources['stacker.news'])[0]
|
return Object.keys(RuntimeSources['stacker.news'])[0]
|
||||||
},
|
},
|
||||||
|
// Use the CDN in production and localhost for development.
|
||||||
|
// assetPrefix: isProd ? 'https://a.stacker.news' : '',
|
||||||
|
async headers () {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: '/_next/:asset*',
|
||||||
|
headers: corsHeaders
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
async rewrites () {
|
async rewrites () {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user