Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,58 @@ const nextConfig = {
},
// Enable standalone output for Docker deployments
output: 'standalone',
async headers() {
return [
{
source: '/manifest.json',
headers: [
{
key: 'Content-Type',
value: 'application/manifest+json; charset=utf-8',
},
],
},
{
source: '/sw.js',
headers: [
{
key: 'Content-Type',
value: 'application/javascript; charset=utf-8',
},
{
key: 'Cache-Control',
value: 'no-cache, no-store, must-revalidate',
},
{
key: 'Service-Worker-Allowed',
value: '/',
},
],
},
{
source: '/:path*',
headers: [
{
key: 'Link',
value: '</manifest.json>; rel="manifest"',
},
],
},
]
},
webpack(config, { isServer, webpack }) {
if (!isServer) {
config.plugins.push(
new webpack.BannerPlugin({
raw: true,
entryOnly: true,
banner:
"if(typeof window!=='undefined'&&'serviceWorker'in navigator){window.addEventListener('load',function(){navigator.serviceWorker.register('/sw.js',{scope:'/',updateViaCache:'none'});});}",
})
)
}
return config
},
}

export default nextConfig
Binary file added public/icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "Aframp - Buy Crypto, Pay Bills & Send Money in Africa",
"short_name": "Aframp",
"description": "Africa's premier cNGN stablecoin payment platform. Buy crypto from ₦2,000, pay bills instantly, and send money across 12 African countries.",
"start_url": "/",
"scope": "/",
"display": "standalone",
"orientation": "portrait-primary",
"background_color": "#0a0a0a",
"theme_color": "#10b981",
"icons": [
{
"src": "/icon-192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any"
},
{
"src": "/icon-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any"
},
{
"src": "/icon-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
]
}
34 changes: 34 additions & 0 deletions public/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const CACHE_NAME = 'aframp-static-v1'

self.addEventListener('install', (event) => {
self.skipWaiting()
})

self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((keys) =>
Promise.all(keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key)))
).then(() => self.clients.claim())
)
})

self.addEventListener('fetch', (event) => {
if (event.request.method !== 'GET') return

const url = new URL(event.request.url)
if (url.origin !== self.location.origin) return
if (url.pathname.startsWith('/api/')) return

event.respondWith(
caches.open(CACHE_NAME).then((cache) =>
fetch(event.request)
.then((response) => {
if (response.ok) {
cache.put(event.request, response.clone())
}
return response
})
.catch(() => cache.match(event.request))
)
)
})
Loading