File size: 1,287 Bytes
091cf52
 
 
 
 
 
 
 
 
 
 
b68e7ef
091cf52
 
b68e7ef
091cf52
 
b68e7ef
 
 
 
 
 
 
 
 
091cf52
 
 
 
b68e7ef
 
091cf52
 
 
 
b68e7ef
091cf52
b68e7ef
091cf52
 
b68e7ef
 
091cf52
 
 
b68e7ef
091cf52
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
// editor.php

$request_uri = $_SERVER['REQUEST_URI'];

// /editor/ を取り除く
$path_without_editor = preg_replace('#^/editor/#', '/', $request_uri);

// ベースURL
$base_url = 'https://soiz1-soiz1-s4s-editor.hf.space';

// 対象URL
$target_url = $base_url . $path_without_editor;

// cURL 初期化
$ch = curl_init($target_url);

// 軽量・高速化のためのオプション
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HEADER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_ENCODING => "", // gzip/deflate 対応
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0, // HTTP/2強制(可能なら)
]);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    http_response_code(502);
    echo "取得エラー: " . curl_error($ch);
    curl_close($ch);
    exit;
}

// ヘッダーとボディを分離
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header_text = substr($response, 0, $header_size);
$body = substr($response, $header_size);

// Content-Type のみ転送(軽量化のため最小限)
if (preg_match('/^Content-Type:\s*(.+)$/im', $header_text, $matches)) {
    header('Content-Type: ' . trim($matches[1]));
}

// そのまま出力
echo $body;
curl_close($ch);
?>