Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k views
in Technique[技术] by (71.8m points)

前端集成 sentry 跨域怎么办?

按照 sentry 文档,将代码集成到前端项目里:

import * as Sentry from '@sentry/react';
import { Integrations } from '@sentry/tracing';

Sentry.init({
  dsn: 'http://xxxx@xxx:9000/2',
  integrations: [new Integrations.BrowserTracing()],
  tracesSampleRate: 1.0
});

但前端项目会报跨域:

我查了 sentry 文档和网上文章,几乎没找到靠谱的解决方案,这个应该怎么解决?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

既然跨域那么就是允许跨域咯。

  1. CORS。 'http://xxxx@xxx:9000/2' 这个服务端配置好。
  2. 本地代理,把 'http://xxxx@xxx:9000/2' 改成 '/2',然后在自己服务端 nginx 配置proxy_pass 咯

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...