Debian Codegraph @

test/manual/cors.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta name="htmx-config" content='{"logAll":true}'>
5 <script src="../../src/htmx.js"></script>
6 <style>
7 body {
8 font-family: system-ui, sans-serif;
9 max-width: 800px;
10 margin: 2rem auto;
11 padding: 1rem;
12 }
13 h1 {
14 font-size: 1.5rem;
15 margin-bottom: 1rem;
16 }
17 button {
18 padding: 0.5rem 1rem;
19 font-size: 1rem;
20 cursor: pointer;
21 }
22 output {
23 display: block;
24 margin-top: 1rem;
25 padding: 1rem;
26 background: #f5f5f5;
27 border-radius: 4px;
28 white-space: pre-wrap;
29 font-family: monospace;
30 font-size: 0.875rem;
31 }
32 output:empty {
33 display: none;
34 }
35 </style>
36 <script>
37 document.addEventListener('htmx:config:request', function(evt) {
38 // Clear htmx headers for CORS requests
39 if (evt.detail.ctx.request.mode === 'cors') {
40 evt.detail.ctx.request.headers = {};
41 }
42 });
43 </script>
44 </head>
45 <body>
46 <h1>CORS Request Test</h1>
47 <p>This button makes a cross-origin request to the GitHub API using <code>mode: cors</code> configuration.</p>
48
49 <button
50 hx-get="https://api.github.com/users/1cg"
51 hx-config="mode: cors"
52 hx-target="#result">
53 Fetch GitHub User @1cg
54 </button>
55
56 <output id="result"></output>
57 </body>