Skip to content

Commit 88cbf1f

Browse files
authored
cors (#237)
1 parent a96ffe7 commit 88cbf1f

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

config/mixpanel.server.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
// This lib is only for server side
2-
import mixpanel from 'mixpanel'
2+
import Mixpanel from 'mixpanel'
33

4-
export default mixpanel.init(process.env.MIXPANEL_ID)
4+
let mixpanel
5+
6+
const initMixpanel = () => {
7+
if (process.env.MIXPANEL_ID) {
8+
mixpanel = Mixpanel.init(process.env.MIXPANEL_ID)
9+
}
10+
}
11+
12+
initMixpanel()
13+
14+
export default mixpanel

next.config.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
module.exports = {
1+
// next.config.js
2+
3+
/** @type {import('next').NextConfig} */
4+
const nextConfig = {
25
reactStrictMode: true,
36
eslint: {
47
ignoreDuringBuilds: true,
58
},
69
swcMinify: true,
10+
async headers() {
11+
return [
12+
{
13+
// matching all API routes
14+
source: "/api/:path*",
15+
headers: [
16+
{ key: "Access-Control-Allow-Credentials", value: "true" },
17+
{ key: "Access-Control-Allow-Origin", value: "*" }, // replace this your actual origin
18+
{ key: "Access-Control-Allow-Methods", value: "GET,DELETE,PATCH,POST,PUT" },
19+
{ key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" },
20+
]
21+
}
22+
]
23+
}
724
}
25+
26+
module.exports = nextConfig

pages/api/[...slug].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function handler(req, res) {
4949
return res.status(400).json({ message: 'Invalid Network' })
5050
}
5151

52-
mixpanel.track('Wallet Discovery Request', {
52+
mixpanel?.track('Wallet Discovery Request', {
5353
type: discoveryRequestType,
5454
network,
5555
fclVersion,

0 commit comments

Comments
 (0)