Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmysql rest api - CORS support #42

Open
impondesk opened this issue Apr 11, 2022 · 1 comment
Open

xmysql rest api - CORS support #42

impondesk opened this issue Apr 11, 2022 · 1 comment

Comments

@impondesk
Copy link

Please provide dev environment versions of your system

node -v ( xmysql requires node >= 7.6.0 ) = v14.17.2
npm -v = 7.24.1
mysql --version = mysql Ver 8.0.26 for macos11.3 on x86_64 (Homebrew)
xmysql --version = undefined

Tried to connect the generated APIs to Angular UI, CORS blocks requests.

Access to XMLHttpRequest at 'localhost:3000/api/consultant' from origin 'http://localhost:4200' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

@somanshusingh
Copy link

somanshusingh commented Jun 7, 2022

@impondesk

in server.js or app.js where the server code written use below code

use : "var cors = require('cors'); app.use(cors())"

example :

`var express = require('express')
var cors = require('cors')
var app = express()

app.use(cors())

app.get('/products/:id', function (req, res, next) {
res.json({msg: 'This is CORS-enabled for all origins!'})
})

app.listen(80, function () {
console.log('CORS-enabled web server listening on port 80')
})`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants