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)
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.