commit
eb9a996ddd
20
CONTRIBUTING.md
Normal file
20
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
## New contributor guide
|
||||||
|
|
||||||
|
To get an overview of the project, read the [README](README.md) file. Here are some resources to help you get started with open source contributions:
|
||||||
|
|
||||||
|
- [Finding ways to contribute to open source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github)
|
||||||
|
- [Set up Git](https://docs.github.com/en/get-started/quickstart/set-up-git)
|
||||||
|
- [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow)
|
||||||
|
- [Collaborating with pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests)
|
||||||
|
|
||||||
|
|
||||||
|
### Pull Request
|
||||||
|
|
||||||
|
When you're finished with the changes, create a pull request, also known as a PR.
|
||||||
|
- Set your PR to go into the <b>dev branch</b>.
|
||||||
|
- Don't forget to [link PR to issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) if you are solving one.
|
||||||
|
- Enable the checkbox to [allow maintainer edits](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork) so the branch can be updated for a merge.
|
||||||
|
Once you submit your PR, a team member will review your proposal. We may ask questions or request additional information.
|
||||||
|
- We may ask for changes to be made before a PR can be merged, either using [suggested changes](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request) or pull request comments. You can apply suggested changes directly through the UI. You can make any other changes in your fork, then commit them to your branch.
|
||||||
|
- As you update your PR and apply changes, mark each conversation as [resolved](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request#resolving-conversations).
|
||||||
|
- If you run into any merge issues, checkout this [git tutorial](https://github.com/skills/resolve-merge-conflicts) to help you resolve merge conflicts and other issues.
|
||||||
|
|
@ -9,4 +9,5 @@ BROKER_USERNAME=""
|
||||||
BROKER_PASSWORD=""
|
BROKER_PASSWORD=""
|
||||||
BROKER_CLIENTID=""
|
BROKER_CLIENTID=""
|
||||||
BROKER_QOS=""
|
BROKER_QOS=""
|
||||||
REST_API_PORT=""
|
REST_API_PORT=""
|
||||||
|
REST_API_CORS="" # addresses must be separated by commas example: "http://localhost:3000,http://myapp.com"
|
||||||
|
|
@ -3,13 +3,16 @@ package cors
|
||||||
import (
|
import (
|
||||||
"github.com/rs/cors"
|
"github.com/rs/cors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetCorsConfig() cors.Cors {
|
func GetCorsConfig() cors.Cors {
|
||||||
|
allowedOrigins := getCorsEnvConfig()
|
||||||
|
fmt.Println(allowedOrigins)
|
||||||
return *cors.New(cors.Options{
|
return *cors.New(cors.Options{
|
||||||
AllowedOrigins: []string{
|
AllowedOrigins: allowedOrigins,
|
||||||
"http://localhost:3000",
|
|
||||||
},
|
|
||||||
AllowedMethods: []string{
|
AllowedMethods: []string{
|
||||||
http.MethodGet,
|
http.MethodGet,
|
||||||
http.MethodPost,
|
http.MethodPost,
|
||||||
|
|
@ -25,3 +28,11 @@ func GetCorsConfig() cors.Cors {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCorsEnvConfig() []string {
|
||||||
|
val, _ := os.LookupEnv("REST_API_CORS")
|
||||||
|
if val == "" {
|
||||||
|
return []string{"*"}
|
||||||
|
}
|
||||||
|
return strings.Split(val, ",")
|
||||||
|
}
|
||||||
2
backend/services/socketio/.env
Normal file
2
backend/services/socketio/.env
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
CORS_ALLOWED_ORIGINS=""
|
||||||
|
# addresses must be separated by commas example: "http://localhost:3000,http://myapp.com"
|
||||||
3
backend/services/socketio/.gitignore
vendored
3
backend/services/socketio/.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
|
.env.local
|
||||||
1089
backend/services/socketio/package-lock.json
generated
1089
backend/services/socketio/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
|
@ -13,6 +13,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@koa/cors": "^4.0.0",
|
"@koa/cors": "^4.0.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
"dotenv": "^16.3.1",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"koa": "^2.14.2",
|
"koa": "^2.14.2",
|
||||||
"socket.io": "^4.6.2"
|
"socket.io": "^4.6.2"
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,24 @@
|
||||||
|
const dotenv = require('dotenv')
|
||||||
|
dotenv.config();
|
||||||
|
dotenv.config({ path: `.env.local`, override: true });
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const app = express();
|
const app = express();
|
||||||
const PORT = 5000;
|
const PORT = 5000;
|
||||||
|
|
||||||
const http = require('http').Server(app);
|
const http = require('http').Server(app);
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
|
var allowedOrigins;
|
||||||
|
let allowedOriginsFromEnv = process.env.CORS_ALLOWED_ORIGINS.split(',')
|
||||||
|
if (allowedOriginsFromEnv.length > 1) {
|
||||||
|
allowedOrigins = allowedOriginsFromEnv
|
||||||
|
}else{
|
||||||
|
allowedOrigins = "*"
|
||||||
|
}
|
||||||
|
console.log("allowedOrigins:",allowedOrigins)
|
||||||
|
|
||||||
const io = require('socket.io')(http, {
|
const io = require('socket.io')(http, {
|
||||||
cors: {
|
cors: {
|
||||||
origin: "http://localhost:3000"
|
origin: allowedOrigins
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user