简体   繁体   English

Adblock 在 React js 上破坏了我的网站(Adblock 阻止所有获取和 axios 请求)

[英]Adblock destroys my site on react js (Adblock blocks all fetch and axios requests)

I made a course project on React JS and uploaded it to the hosting.我做了一个关于 React JS 的课程项目并将其上传到托管。 After I sent my site to a friend, he said that almost nothing works for him, either eternal downloads, or the site does not return validation results, and others.在我将我的站点发送给一位朋友后,他说几乎没有什么对他有用,无论是永久下载,还是该站点不返回验证结果,等等。 When I started to understand, I realized that he had errors "Failed to load resource:.net::ERR_BLOCKED_BY_CLIENT", after disabling the Adblock extension, all the functionality of the site began to work properly.当我开始了解时,我意识到他有错误“加载资源失败:.net::ERR_BLOCKED_BY_CLIENT”,禁用Adblock扩展后,网站的所有功能开始正常工作。 In my question, there is no question of trifles, such as blocking images, absolutely all requests to the server are blocked for me.在我的问题中,没有任何琐碎的问题,例如阻止图像,对我来说绝对阻止了对服务器的所有请求。 My site is designed so that on the front there is only a visual and requests for the back, and on the back, all user actions are processed and the result is returned, on which the actions of the front depend, you can see for yourself, " site " that I have constant errors in the console on the client side, and when you disable the ad blocker, everything starts working.我的网站是这样设计的,前面只有视觉和请求后面,后面处理所有用户操作并返回结果,前面的动作依赖于它,你自己看,“网站”,我在客户端的控制台中不断出现错误,当您禁用广告拦截器时,一切都会开始工作。 My code is quite large, but if you have suspicions about some specific code sections, then I can provide them.我的代码相当大,但如果您对某些特定代码部分有疑问,那么我可以提供它们。 Below is one of the usual requests to the server, most of them are, there are a couple more axios requests, but there are very few of them, but they are also blocked.下面是对服务器的一个常见请求,大部分都是,还有几个 axios 请求,但是很少,但是也被屏蔽了。 I also saw similar problems with ajax requests on other threads, but I never saw a specific reason for all the blocks.我在其他线程上也看到了 ajax 请求的类似问题,但我从未看到所有阻塞的具体原因。

        var form = new FormData()
    form.append('JSONPARSE',true);
    fetch("http://g908020p.beget.tech",{
        method: 'POST',
        body: form
    })
    .then(response => response.text())
    .then(response => {
        var json = JSON.parse(response)
        setCatalog(json.items)
        setLoading(true)
        console.log(json)

    })
    .catch(error => {
        console.log(error)
    })

Yes, related to this post, the adblock parses the URL for some pattern.是的,与这篇文章相关,adblock 解析 URL 以获得某种模式。

I cheated this by using a third party server that wrapped my request.我通过使用包装我的请求的第三方服务器来作弊。
Check it out:看看这个:
https://codetabs.com/cors-proxy/cors-proxy.html https://codetabs.com/cors-proxy/cors-proxy.html

  fetch("https://api.codetabs.com/v1/proxy?quest=http://g908020p.beget.tech")

Of course you can wrap it with your own server.当然你可以用你自己的服务器包装它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM