|
1 | 1 |
|
2 | 2 |
|
| 3 | +<!DOCTYPE html> |
3 | 4 |
|
4 | | -<html> |
5 | 5 |
|
| 6 | +<html> |
6 | 7 |
|
7 | 8 | <head> |
8 | | - |
| 9 | + <meta charset=utf-8> |
9 | 10 |
|
10 | | - <title></title> |
| 11 | + <title> |
| 12 | + Simple Proxy |
| 13 | + </title> |
11 | 14 |
|
12 | | - <base href='https://javascript-2020.github.io/blog/27-07-25/simple-proxy/simple-proxy.html'> |
13 | | - |
| 15 | + <meta name=description content='Learn how to build a simple HTTP proxy server in Node.js with step-by-step code examples. Perfect for beginners exploring networking, request forwarding, and basic server setup.'> |
14 | 16 | <link rel=icon type='image/png' href='/blog/image/blog-30.png'> |
| 17 | + <meta name=viewport content='width=device-width, initial-scale=1'> |
| 18 | + |
| 19 | + <base href='https://ext-code.com/blog/25-07-27/simple-proxy/'> |
| 20 | + <link rel=canonical href='https://ext-code.com/blog/25-07-27/simple-proxy/simple-proxy.html'> |
15 | 21 |
|
16 | | - <link rel=stylesheet href='/blog/css/blog.css'> |
17 | 22 |
|
| 23 | + <script type='application/ld+json'> |
18 | 24 |
|
19 | | - </head> |
20 | | - |
21 | | - |
22 | | - <body> |
| 25 | + { |
| 26 | + "@context" : "https://schema.org", |
| 27 | + "@type" : "TechArticle", |
| 28 | + "headline" : "Simple Proxy", |
| 29 | + "description" : "Learn how to build a simple HTTP proxy server in Node.js with step-by-step code examples. Perfect for beginners exploring networking, request forwarding, and basic server setup.", |
| 30 | + "author" : {"@type":"Person","name":"Matthew Richards"}, |
| 31 | + "datePublished" : "2025-07-27", |
| 32 | + "dateModified" : "2025-10-22", |
| 33 | + "mainEntityOfPage" : {"@type":"WebPage","@id":"https://ext-code.com/blog/25-07-27/simple-proxy/simple-proxy.html"}, |
| 34 | + "publisher" : {"@type":"Organization","name":"ext-code.com","logo":{"@type":"ImageObject","url":"https://ext-code.com/favicon.ico"}}, |
| 35 | + } |
| 36 | + |
| 37 | + </script> |
23 | 38 |
|
24 | 39 |
|
25 | | - |
26 | | - <h3> |
27 | | - simple proxy |
28 | | - </h3> |
29 | 40 |
|
| 41 | + <script src='https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js'></script> |
30 | 42 |
|
31 | | - <div id=desc> |
32 | 43 |
|
33 | | -simple proxy |
| 44 | + <script src='https://libs.ext-code.com/js/dom/component/component.js'></script> |
34 | 45 |
|
35 | | - </div> |
36 | 46 |
|
| 47 | + <script init> |
| 48 | + console.clear(); |
| 49 | + console.log('simple-proxy.html'); |
| 50 | + console.log(); |
| 51 | + console.json=v=>console.log(JSON.stringify(v,null,4)); |
| 52 | + var df=true,version='v2.0' |
| 53 | + ; |
37 | 54 |
|
38 | | - <code></code> |
39 | | - |
| 55 | + |
| 56 | + var ext; |
| 57 | + var $; |
| 58 | + var datatype; |
| 59 | + var menumod; |
| 60 | + var keydown; |
| 61 | + var debug; |
| 62 | + |
| 63 | + |
| 64 | + var ace; |
| 65 | + |
| 66 | + var menu; |
40 | 67 |
|
41 | | - <script> |
42 | | - console.clear(); |
| 68 | + var example; |
| 69 | + |
| 70 | + var log; |
| 71 | + |
| 72 | + |
| 73 | + //: |
43 | 74 |
|
| 75 | + |
| 76 | + async function init(){ |
| 77 | + //debug('init',version); |
| 78 | + |
| 79 | + menu = menumod(); |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + example = mod.example; |
| 84 | + log = mod.log; |
| 85 | + |
| 86 | + example.initmod({ext,$,menu,ace}); |
| 87 | + log.initmod({ext,$}); |
| 88 | + |
| 89 | + await Promise.all([ |
| 90 | + example.init(), |
| 91 | + log.init(), |
| 92 | + ]); |
| 93 | + |
| 94 | + |
| 95 | + initdom(document.body); |
| 96 | + |
| 97 | + |
| 98 | + }//init |
| 99 | + |
| 100 | + |
| 101 | + //: |
| 102 | + |
| 103 | + |
44 | 104 | (async()=>{ |
45 | 105 |
|
46 | | - var url = window.location.toString(); |
47 | | - console.log(url); |
48 | | - if(url.includes('about:')){ |
49 | | - var base = document.querySelector('base'); |
50 | | - url = base.href; |
51 | | - } |
52 | | - |
53 | | - var i = url.lastIndexOf('/'); |
54 | | - var fn = url.slice(i+1); |
55 | | - var i = fn.lastIndexOf('.'); |
56 | | - fn = fn.slice(0,i); |
57 | | - fn += '.js'; |
58 | | - console.log(fn); |
| 106 | + mod.stack.add; |
59 | 107 |
|
60 | | - var res = await fetch(fn); |
61 | | - var txt = await res.text(); |
| 108 | + ({ext} = await import('https://libs.ext-code.com/js/io/ext-loader/ext-loader.m.js')); |
| 109 | + |
| 110 | + var promise = ext.load.libs( |
| 111 | + 'js/dom/$.js.api', |
| 112 | + 'js/core/datatype.js', |
| 113 | + 'js/dom/menumod/menumod.js', |
| 114 | + 'js/dom/keydown/keydown.js', |
| 115 | + 'js/dom/code/v2.0/code-v2.0.js.api', |
| 116 | + 'js/debug/debug.js', |
| 117 | + ); |
| 118 | + [$,datatype,menumod,keydown,code,debug] = await promise; |
| 119 | + |
| 120 | + code.initmod({ext,$,datatype,menumod}); |
62 | 121 |
|
63 | | - var code = document.querySelector('code'); |
64 | | - code.textContent = txt; |
| 122 | + [srcdoc] = await ext.text.github('javascript-2020:javascript-2020.github.io:main:blog/25-07-25/http-streaming-download/ex/srcdoc.html'); |
65 | 123 |
|
| 124 | + mod.stack.complete; |
| 125 | + |
66 | 126 | })(); |
67 | 127 |
|
68 | | - </script> |
| 128 | + |
| 129 | + </script init> |
| 130 | + |
| 131 | + |
| 132 | +<!-- |
| 133 | + //: |
| 134 | +--> |
| 135 | + |
| 136 | + |
| 137 | + <link rel=stylesheet href='/blog/css/blog.css'> |
| 138 | + |
| 139 | + <style> |
| 140 | + |
| 141 | + html |
| 142 | + {height:100%;font-family:arial} |
| 143 | + body |
| 144 | + {min-height:calc(100% - 40px);display:flex;flex-direction:column;gap:20px;margin:20px;align-items:center; |
| 145 | + padding-bottom:200px; |
| 146 | + } |
| 147 | + body>* |
| 148 | + {max-width:1400px;width:100%;padding:0 20px;} |
| 149 | + |
| 150 | + [component] |
| 151 | + {display:none} |
| 152 | + |
| 153 | + .description |
| 154 | + {max-width:1000px;text-align:justify;border-left:4px solid #4a90e2;padding:1rem; |
| 155 | + background-color:#f9f9f9;font-family:system-ui,sans-serif;font-size:1rem;line-height:1.6;color:#333} |
| 156 | + .description>p |
| 157 | + {margin:0} |
| 158 | + .description > p+p |
| 159 | + {margin:10px 0} |
| 160 | + |
| 161 | + code |
| 162 | + {font-family:monospace;background:whitesmoke} |
| 163 | + code.inline |
| 164 | + {display:inline;padding:5px 10px} |
| 165 | + |
| 166 | + a |
| 167 | + {color:#4a90e2;text-decoration:none;font-weight:500} |
| 168 | + a:hover |
| 169 | + {text-decoration:underline} |
| 170 | + .link-domain |
| 171 | + {font-size:0.85rem;color:#777;margin-left:0.25rem} |
| 172 | + .link-txt |
| 173 | + {} |
| 174 | + |
| 175 | + input |
| 176 | + {font-size:16px;padding:5px 7px;box-sizing:border-box;} |
| 177 | + input[type=button] |
| 178 | + {cursor:pointer} |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | + </style> |
| 183 | + |
| 184 | + </head> |
| 185 | + |
| 186 | + |
| 187 | + <body> |
| 188 | + |
| 189 | + |
| 190 | + <blog-hdr component=grp1 v2.0> |
| 191 | + <h1 class=title> |
| 192 | + Simple Proxy |
| 193 | + </h1> |
| 194 | + <time slot=date datetime=2025-10-22> |
| 195 | + 22 Oct 2025 |
| 196 | + </time> |
| 197 | + </blog-hdr> |
| 198 | + |
69 | 199 |
|
| 200 | + <div class=description> |
| 201 | + |
| 202 | + <p> |
| 203 | + Learn how to build a simple HTTP proxy server in Node.js with step-by-step code examples. Perfect for beginners exploring |
| 204 | + networking, request forwarding, and basic server setup. |
| 205 | + </p> |
| 206 | + |
| 207 | + </div> |
| 208 | + |
| 209 | + |
| 210 | + <editor id=example component v2.0 src='ex/simple-proxy.js'></editor> |
| 211 | + |
| 212 | + |
| 213 | + <log component v2.0></log> |
| 214 | + |
| 215 | + |
70 | 216 | </body> |
| 217 | + |
| 218 | + |
| 219 | + <script> |
| 220 | + |
| 221 | + |
| 222 | + function initdom(rootnode){ |
| 223 | + |
| 224 | + example.initdom(); |
| 225 | + log.initdom(); |
| 226 | + |
| 227 | + }//initdom |
| 228 | + |
| 229 | + |
| 230 | + </script> |
71 | 231 |
|
72 | 232 |
|
73 | 233 | </html> |
|
0 commit comments