Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS error to us-assets.i.posthog #27032

Open
typefox09 opened this issue Dec 19, 2024 · 0 comments
Open

CORS error to us-assets.i.posthog #27032

typefox09 opened this issue Dec 19, 2024 · 0 comments
Labels
bug Something isn't working right

Comments

@typefox09
Copy link

typefox09 commented Dec 19, 2024

Bug Description

Bug description

I am getting the following error when using Posthog Cloud (not self hosted):

Access to XMLHttpRequest at 'https://us-assets.i.posthog.com/array/phc_FRkS0YOcYGQuxJhYlaTKH5u6j1vbpAVqwuPpSCf3i5N/config?ip=1&_=1734571510365&ver=1.201.1' from origin 'http://localhost:3000' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

It does seem that events are getting sent, however this is showing on both local host and production in the dev console.

I am using Nuxt 3 without SSR.

Initialization code:

`export default defineNuxtPlugin(nuxtApp => {
const runtimeConfig = useRuntimeConfig();
const IS_DEV = import.meta.env.MODE === 'development'
const route = useRoute();

const posthogClient = posthog.init(runtimeConfig.public.posthogPublicKey, <PostHogConfig | any>{
api_host: runtimeConfig.public.posthogHost || 'https://us.i.posthog.com',
person_profiles: 'identified_only',
capture_pageview: false, // we add manual pageview capturing below
autocapture:false,
debug: false,
mask_all_text: true,
capture_dead_clicks: true,
disable_session_recording: IS_DEV,
session_recording: {
maskAllInputs: true,
maskTextSelector: "*",
},
before_send: (event: CaptureResult | null): CaptureResult | null => {
// Do not send events if we are in dev mode
if (IS_DEV) {
// if (event) {
// console.log('posthog event: ' + event.event, event)
// }
return null
} else {
return event
}
},
// loaded: (posthog) => {
// // if (import.meta.env.MODE === 'development') posthog.debug();
// }
})

// Make sure that pageviews are captured with each route change
const router = useRouter();
router.afterEach((to) => {
nextTick(() => {
posthog.capture('$pageview', {
current_url: to.fullPath
});
});
});

return {
provide: {
posthog: () => posthogClient
}
}

return
})

`

Screenshot 2024-12-19 at 12 26 26 PM

@typefox09 typefox09 added the bug Something isn't working right label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working right
Projects
None yet
Development

No branches or pull requests

1 participant