Using Next.js
Please use at least version 1.6.0 of @spindl-xyz/attribution or @spindl-xyz/attribution-lite for this feature.
1. Add Next.js Code
Option 1) Using Rewrites as proxy
Add ingest route that using rewrites() method forwards the data to https://spindl.link/ in your next.config file
// next.config.js OR next.config.ts
const nextConfig = {
async rewrites() {
return [
{
source: "/ingest/:path*",
destination: "https://spindl.link/:path*",
},
];
},
// ...
}
module.exports = nextConfigThis should work! If you're experiencing any issues, Option 2 is an alternative!
Option 2) Use Custom Middleware using App Router
If option 1 doesn't work, you can write a custom middleware middleware.js/ts in your base directory (your app folder) to point /ingest url to our spindl.link hostname
2. Configure Spindl SDK host with the proxy
Add host url to spindl configure object with the proxy host url
You can use the window.location.origin as part of host url but in SSR contexts like Next.js you may need to check if window is defined first
Last updated