跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[问与答] 关于 CF workers 反代后的网站无法内嵌问题

发表于

请问各位大佬。我用 CF 的 worker 反代了 google 的学术镜像站。现在有个问题是当吧镜像站内嵌在网站的某个页面里时候,发现打不开网站。浏览器抓包提示的是因为是 (‘X-Frame-Options’); 是 sameOrigin 导致,应该就是不允许跨域问题,这种情况下该怎么能让这个镜像站内嵌呢。 我根据 GPT 的提示,在请求的时候删除掉 这个 X-FRAME-OPTIONS ,发现并无什么卵用。代码如下,请问各位大佬如何实现内嵌呢?

` export default { async fetch(request, env) { const _url = new URL(request.url); const hostname = _url.hostname; _url.hostname = "scholar.google.com";

const req = new Request(_url, request);
req.headers.set('Referer', 'https://scholar.google.com/');
req.headers.set('Origin', 'https://scholar.google.com/');
req.headers.delete('X-Frame-Options');

const res = await fetch(req);
const newRes = new Response(res.body, res);

newRes.headers.set('Access-Control-Allow-Origin', '*');
newRes.headers.set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
newRes.headers.set('Access-Control-Allow-Headers', 'Content-Type');

let location = newRes.headers.get('location');
if (location !== null && location !== "") {
  location = location.replace('://scholar.google.com/', '://' + hostname);
  newRes.headers.set('location', location);
}

return newRes;

}, };

`

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.