fix: add cors to register endpoint
This commit is contained in:
parent
3ae1387c79
commit
85954e479e
3 changed files with 8 additions and 1 deletions
|
|
@ -3,4 +3,4 @@
|
||||||
Differences from main lamassu-admin:
|
Differences from main lamassu-admin:
|
||||||
|
|
||||||
- `bin/new-lamassu-register <username>` to add a user
|
- `bin/new-lamassu-register <username>` to add a user
|
||||||
- `bin/insecure-dev` to run the server
|
- `bin/insecure-dev.sh` to run the server
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const https = require('https')
|
const https = require('https')
|
||||||
|
const cors = require('cors')
|
||||||
const helmet = require('helmet')
|
const helmet = require('helmet')
|
||||||
const cookieParser = require('cookie-parser')
|
const cookieParser = require('cookie-parser')
|
||||||
const { ApolloServer, AuthenticationError } = require('apollo-server-express')
|
const { ApolloServer, AuthenticationError } = require('apollo-server-express')
|
||||||
|
|
@ -49,6 +50,9 @@ apolloServer.applyMiddleware({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// cors on app for /api/register endpoint.
|
||||||
|
app.use(cors({ credentials: true, origin: devMode && 'https://localhost:3000' }))
|
||||||
|
|
||||||
app.get('/api/register', (req, res, next) => {
|
app.get('/api/register', (req, res, next) => {
|
||||||
const otp = req.query.otp
|
const otp = req.query.otp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ const AuthRegister = () => {
|
||||||
useAxios({
|
useAxios({
|
||||||
url: `https://localhost:8070/api/register?otp=${query.get('otp')}`,
|
url: `https://localhost:8070/api/register?otp=${query.get('otp')}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
options: {
|
||||||
|
withCredentials: true
|
||||||
|
},
|
||||||
trigger: [],
|
trigger: [],
|
||||||
customHandler: (err, res) => {
|
customHandler: (err, res) => {
|
||||||
if (err) return
|
if (err) return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue