当前位置: 首页 > news >正文

apache2 server settings

 

(índice):1 Access to fetch at 'http://10.10.1.69/collins.json' from origin 'https://www.collinsdictionary.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

how to solve this issue?

 

You've hit the classic web security "wall." Because you are on collinsdictionary.com (HTTPS), the browser is protecting that site from making unauthorized requests to your local IP (HTTP).

Since you likely control the Apache server on 10.10.1.69, you can solve this by telling Apache to send a "hall pass" (CORS header) to the browser.


Option 1: The "Proper" Fix (Modify Apache)

You need to enable the headers module in Apache and configure it to allow requests from other origins.

  1. Enable the headers module:

    Bash
     
    sudo a2enmod headers
    
  2. Edit your Apache configuration:

    Open the default site config:

    Bash
     
    sudo nano /etc/apache2/sites-enabled/000-default.conf
    
  3. Add the Header line:

    Inside the <VirtualHost *:80> block, add this line:

    Apache
     
    Header set Access-Control-Allow-Origin "*"
    

    (Note: Using "*" allows any site to read the file. For a lab machine, this is fine. In production, you'd replace * with the specific domain.)

  4. Restart Apache:

    Bash
     
    sudo systemctl restart apache2
    

Option 2: The "Quick & Dirty" Fix (No Config)

If you don't want to mess with Apache settings, the easiest way to bypass CORS in the console is to navigate the browser to a neutral page.

  1. In Chrome, open a completely blank tab.

  2. In the address bar, type about:blank and hit Enter.

  3. Now try running your fetch() code in that console.

Because about:blank has no "origin," Chrome often relaxes the CORS requirements for local IP requests. Even better, just navigate to http://10.10.1.69/ directly and run the code there.


Option 3: Use a Chrome Extension (For Testing Only)

If you do this often, you can install a Chrome extension like "Allow CORS: Access-Control-Allow-Origin." * How it works: It intercepts the browser's request and "fakes" the permission header.

  • Warning: Turn this OFF when you aren't testing, as it effectively disables a major security feature of your browser.

Why is this happening?

The browser performs a Preflight Request. It asks the server: "Hey, is it okay if this random website reads your files?" If Apache doesn't respond with Access-Control-Allow-Origin, the browser assumes the answer is "No" and blocks the data to protect your privacy.

Which of these approaches sounds easier for your current project?

 

 

 

in Firefox console,

run this piece of code:

 

const response = await fetch('http://10.10.1.69/collins.en2es.json');

const data = await response.json();

console.log(data.length);

 

I get this: Blocked loading mixed active content “http://10.10.1.69/collins.en2es.json” www.collinsdictionary.com

 

Firefox is being even stricter than Chrome here. This isn't just a CORS issue; it is a Mixed Content block.

Because you are on https://www.collinsdictionary.com (Secure), Firefox refuses to let you fetch data from http://10.10.1.69 (Insecure). It views this as a security downgrade—basically, a secure site shouldn't be allowed to talk to an unencrypted source because a "man-in-the-middle" could swap your JSON file with malicious code.

The Quickest Fix (The "Same-Origin" Trick)

The simplest way to bypass both Mixed Content and CORS without changing any settings is to run the code from a page that is already on your server.

  1. In your Firefox address bar, go to: http://10.10.1.69/

  2. Open the Console (F12).

  3. Run your code again:

    JavaScript
     
    const response = await fetch('http://10.10.1.69/collins.en2es.json');
    const data = await response.json();
    console.log(data.length);
    

Because you are now on an http page, Firefox won't trigger the "Mixed Content" alarm, and because you are fetching from the same IP, CORS won't block you.


The "Force it to work on Collins" Fix

If you absolutely must run this while looking at the Collins Dictionary website, you have to tell Firefox to lower its guard for that specific tab:

  1. Look at the Address Bar in Firefox.

  2. On the far left (next to the URL), you should see a Shield Icon or a Lock Icon with a warning.

  3. Click it and select "Disable protection for now" (it might say "Enhanced Tracking Protection is ON" or show a "Permissions" section).

  4. Alternatively, you can go to about:config in a new tab, search for security.mixed_content.block_active_content, and set it to false (Not recommended for daily browsing, turn it back on afterward!).

Why did Chrome and Firefox give different errors?

  • Chrome focused on the CORS violation (Origin A vs Origin B).

  • Firefox stopped you even earlier because of the Mixed Content violation (HTTPS vs HTTP). Active content (like a fetch call) is blocked by default in almost all modern browsers when initiated from a secure site to an insecure one.

Is the goal to script some data processing against the Collins site, or are you just trying to verify your JSON data?

 

 

 

tell me how to execute this js http://10.10.1.69/my.js on my firefox console.

 

Since you are dealing with the same Mixed Content and CORS restrictions as before, you can't simply "fetch" and run the script while you are on a secure site like Collins Dictionary.

To execute a remote script directly in the Firefox console, you have three main ways to do it, depending on how much "security friction" you want to deal with.


Option 1: The "Direct Injection" Method (Recommended)

This is the cleanest way. It creates a <script> tag, points it to your Kali server, and attaches it to the webpage.

Note: For this to work, you must be on an http page (like http://10.10.1.69) or have disabled "Enhanced Tracking Protection" in Firefox for the site you are on.

JavaScript
 
var script = document.createElement('script');
script.src = 'http://10.10.1.69/my.js';
document.head.appendChild(script);

Option 2: The "Fetch and Eval" Method

If you want to load the code and execute it immediately as a string, you can use eval().

JavaScript
 
fetch('http://10.10.1.69/my.js').then(response => response.text()).then(code => {eval(code);});
  • Pros: Gives you control over when the code runs.

  • Cons: Will be blocked by CORS unless you added the Header set Access-Control-Allow-Origin "*" to your Apache config earlier.


Option 3: The "No-Code" Way (The Easiest)

If you are just trying to test the logic in my.js:

  1. Open your browser and go to http://10.10.1.69/my.js.

  2. The browser will display the raw text of your JavaScript file.

  3. Ctrl+A (Select All) and Ctrl+C (Copy).

  4. Go to the tab where you want to run it, open the Console (F12).

  5. Ctrl+V (Paste) and hit Enter.

This bypasses every single security restriction (CORS, Mixed Content, etc.) because you are manually providing the code rather than asking the browser to fetch it.


Troubleshooting Firefox Security

If you try Option 1 or 2 and see a "Blocked" message in the console, Firefox is protecting you from Mixed Content.

  1. Look for the Shield Icon to the left of the URL bar.

  2. Turn OFF "Enhanced Tracking Protection" for that site.

  3. If it's a "Mixed Active Content" error, click the Lock Icon -> Connection Secure -> Disable Protection for now.

Quick Tip: If your my.js is meant to work with that collins.json file, make sure the JSON fetch inside the script uses the full URL (http://10.10.1.69/collins.json) so it doesn't try to look for the file on the Collins Dictionary servers!

 

 

 

http://www.jsqmd.com/news/774681/

相关文章:

  • AI智能体工具集成平台Composio:从核心概念到实战部署
  • 事件驱动AI智能体开发:基于inngest/agent-kit构建可靠应用
  • Jest Preview:前端测试可视化调试工具的原理、配置与实战
  • ARM中断系统架构与优先级优化实践
  • ESP32-C3蓝牙开发避坑指南:从零到一搞懂ESP-IDF里的那些BLE示例(保姆级梳理)
  • semi-utils:摄影师的智能水印解决方案,让批量处理变得简单高效
  • Elasticsearch 9.4 为 Elastic AI 生态系统的下一阶段提供支持:Dell AI Data Platform(与 NVIDIA 合作)
  • 2026年靠谱的PP立式储罐/PP污水储罐/苏州PP立式储罐生产厂家推荐 - 行业平台推荐
  • OpenClaw 全套落地包(可直接复制即用)
  • 别再只用While循环了!LabVIEW FPGA里这个‘单周期定时循环’到底强在哪?
  • STM32实战:基于STM32F103的智能输液监控系统(液滴检测+报警)
  • 3秒安全弹出USB设备:告别Windows设备占用难题的高效解决方案
  • AI工具精选列表:从分类解析到实战应用的全方位指南
  • 基于LiveKit与LangGraph构建实时语音AI通话代理的完整指南
  • 2026年质量好的十字型封箱机/封箱机/苏州折盖封箱机/苏州自适应封箱机精选厂家推荐 - 品牌宣传支持者
  • C语言第3讲:分支和循环
  • Kimi K2.5智能设备两周深度体验与性能评测
  • 抖音下载器:免费快速批量下载抖音视频的终极解决方案
  • 2026年质量好的恒压供水水泵/辽宁水冷式水泵优质厂家汇总推荐 - 行业平台推荐
  • 开源智能仪表盘OpenJarvisDashboard:开发者效率工具全解析
  • 别再手动算线宽了!用这个Matlab函数快速搞定微带线设计(附ADS对比验证)
  • 量子计算与高性能计算融合架构解析
  • Twinny:免费离线的AI代码补全工具部署与调优指南
  • 自动驾驶仿真训练平台SIMSCALE的技术解析与应用实践
  • 多核处理器在嵌入式与通信领域的优化实践
  • FedAvg联邦学习实战避坑指南:数据非独立同分布(Non-IID)到底有多坑?
  • 2026年质量好的联合板木箱/木箱/工业设备包装木箱口碑好的厂家推荐 - 行业平台推荐
  • YOLOv8改进 | 检测头篇 |最新HyCTAS模型提出SAttention(自研轻量化检测头 -> 适用分割、Pose、目标检测)
  • 为AI Agent集成实时搜索能力:基于Council Tavily Search的实践指南
  • 2026年评价高的深井潜水泵/鱼塘潜水泵口碑好的厂家推荐 - 品牌宣传支持者