coqui-ai / STT-examples

🐸STT integration examples
https://github.com/coqui-ai/STT
Mozilla Public License 2.0
116 stars 45 forks source link

Feature request: make web_microphone_websocket work outside localhost #27

Open comodoro opened 2 years ago

comodoro commented 2 years ago

The web_microphone_websocket example works for localhost, but on a domain there were CORS errors from the socket.io code, e.g. Chrome:

Access to XMLHttpRequest at 'https://example.com:4000/socket.io/?EIO=3&transport=polling&t=Nu-iT4E' from origin 'https://example.com.cz:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Several recipes from SO and the socket.io docs did not work, perhaps someone with better JS knowledge might help.

neural-loop commented 2 years ago

Hi Comodoro are you still looking for this

comodoro commented 2 years ago

Yes, my attempts were unsuccessful as I have zero experience with socket.io and rusty with JavaScript.

On Sat, 12 Mar 2022, 23:41 Justin Riddiough, @.***> wrote:

Hi Comodoro are you still looking for this

— Reply to this email directly, view it on GitHub https://github.com/coqui-ai/STT-examples/issues/27#issuecomment-1065977951, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHB6GWER6NZ6SD6YMS27HDU7UMR5ANCNFSM5LRY2NOQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

neural-loop commented 2 years ago

Try this in the server.js:

const app = http.createServer(function (req, res) {
    const headers = {
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Max-Age': 2592000, // 30 days
        /** add other headers as per requirement */
    };
    res.writeHead(200, headers);
    res.write('STT');
    res.end();
});

const io = socketIO(app, {});
io.set('origins', '*:*');