29 lines
984 B
TypeScript
29 lines
984 B
TypeScript
if (typeof window !== 'undefined' && window.happyDOM) {
|
|
window.happyDOM.setURL('http://172.16.74.149:5666/');
|
|
window.happyDOM.settings.fetch.interceptor = {
|
|
async beforeAsyncRequest({ request }) {
|
|
const { Response } = window;
|
|
const url = request.url;
|
|
if (!Response) return undefined;
|
|
if (url.startsWith('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js')) {
|
|
return new Response('window.__mockJQueryLoaded = true;', {
|
|
status: 200,
|
|
headers: { 'content-type': 'application/javascript' },
|
|
});
|
|
}
|
|
if (
|
|
url.startsWith('http://localhost:3000') ||
|
|
url.startsWith('http://127.0.0.1:3000') ||
|
|
url.startsWith('http://[::1]:3000') ||
|
|
url.startsWith('http://172.16.74.149:5666')
|
|
) {
|
|
return new Response('', {
|
|
status: 200,
|
|
headers: { 'content-type': 'application/javascript' },
|
|
});
|
|
}
|
|
return undefined;
|
|
},
|
|
};
|
|
}
|