banner
LAPLACE

LAPLACE By 王友元

那些娇艳欲滴姿态万千的花朵其实都依赖于某种神秘的养料——那就是人类幽微而真挚的情感故事
telegram
x
email

Use Cloudflare to reverse proxy Spotify and display embedded tracks on domestic websites.

soptify itself is not blocked, but open.spotify.com cannot be accessed due to the Great Firewall. This prevents the embedded code with open.spotify.com from loading and displaying. To enable online streaming, a simple reverse proxy for open.spotify.com can be implemented.

Here is an example:

Go to Workers and Pages.
Create a worker with the following code:

addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
const url = new URL(request.url);
url.hostname = 'open.spotify.com';
const headers = new Headers(request.headers);
const response = await fetch(url.toString(), {
  method: request.method,
  headers: headers,
  body: request.body,
});
const responseHeaders = new Headers(response.headers);
return new Response(response.body, {
  status: response.status,
  statusText: response.statusText,
  headers: responseHeaders,
});
}

Bind the worker to your own domain in Settings - Triggers - Custom Domain
(The default worker domain generated by Cloudflare is blocked and cannot be used)
image

That's it. It's a standard CF worker reverse proxy process. Just change the domain of the embedded Spotify link to the one we just bound.

_L4F2_IO(2I$I(NPLKOLE

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.