fix: add cors to register endpoint

This commit is contained in:
Taranto 2020-01-02 14:59:21 +00:00 committed by Josh Harvey
parent 3ae1387c79
commit 85954e479e
3 changed files with 8 additions and 1 deletions

View file

@ -3,4 +3,4 @@
Differences from main lamassu-admin:
- `bin/new-lamassu-register <username>` to add a user
- `bin/insecure-dev` to run the server
- `bin/insecure-dev.sh` to run the server

View file

@ -1,6 +1,7 @@
const fs = require('fs')
const express = require('express')
const https = require('https')
const cors = require('cors')
const helmet = require('helmet')
const cookieParser = require('cookie-parser')
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) => {
const otp = req.query.otp

View file

@ -13,6 +13,9 @@ const AuthRegister = () => {
useAxios({
url: `https://localhost:8070/api/register?otp=${query.get('otp')}`,
method: 'GET',
options: {
withCredentials: true
},
trigger: [],
customHandler: (err, res) => {
if (err) return