Blocked by CORS policy #198
Answered
by
ghost
ghost
asked this question in
Help / Questions
-
Hey I just tried this for an https server with cors : import { writeFileSync, readFileSync } from "fs";
import { geckos } from "@geckos.io/server";
import { generate } from "selfsigned";
import { createServer } from "https";
import express from "express";
import cors from "cors";
const server = geckos({
authorization: function (auth, request, response) {
return request.socket.remoteAddress
},
label: "wild.io",
cors: { origin: "*", allowAuthorization: true }
});
const attrs = [{ name: "commonName", value: "contoso.com" }];
const pems = generate(attrs, { days: 365 });
writeFileSync("cert/private", pems.private);
writeFileSync("cert/public", pems.public);
writeFileSync("cert/cert", pems.cert);
const options = {
key: readFileSync("cert/private"),
cert: readFileSync("cert/cert"),
}
const app = express();
app.use(cors());
const httpsServer = createServer(options, app)
server.addServer(httpsServer);
app.use(express.static("public"));
httpsServer.listen(8080);
server.onConnection(function(socket) {
//...
}); But still getting the cors error : Am I doing something wrong ? |
Beta Was this translation helpful? Give feedback.
Answered by
ghost
Apr 30, 2022
Replies: 2 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
3 replies
-
I used let's encrypt instead of self-signed and it seem to work |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used let's encrypt instead of self-signed and it seem to work