Browse Source

fixing shit

logicp 6 years ago
parent
commit
86536961a5
2 changed files with 17 additions and 17 deletions
  1. 2 2
      src/form.js
  2. 15 15
      src/server/index.js

+ 2 - 2
src/form.js

@@ -107,7 +107,7 @@ class TextFields extends React.Component {
       significantOther: this.state.significantOther,
     })
 
-    const response = await fetch('http://christmas.logicp.ca/api/attendee', {
+    const response = await fetch('/api/attendee', {
       method: 'post',
       body: body,
       headers: new Headers({
@@ -123,7 +123,7 @@ class TextFields extends React.Component {
 
   fetchAttendees = async () => {
     let attendees
-    await fetch('http://christmas.logicp.ca/api/list', {
+    await fetch('/api/list', {
       method: 'get',
     }).then(data => {
       data.json().then(finalData => {

+ 15 - 15
src/server/index.js

@@ -1,7 +1,7 @@
 const Sequelize = require('sequelize');
 const express = require("express");
 const bodyParser = require("body-parser");
-const cors = require('cors')
+// const cors = require('cors')
 require('dotenv').config({ path: '.env.local' });
 
 const database = new Sequelize({
@@ -15,18 +15,18 @@ const Attendee = database.define('attendee', {
   cat: Sequelize.STRING
 });
 
-const whitelist = ['http://localhost:3001', 'http://localhost', 'http://127.0.0.1', 'http://christmas.logicp.ca']
+// const whitelist = ['http://localhost:3001', 'http://localhost', 'http://127.0.0.1', 'http://christmas.logicp.ca']
 
-const corsOptions = {
-  origin: function (origin, callback) {
-    console.log('request attempted from ', origin)
-    if (whitelist.indexOf(origin) !== -1) {
-      callback(null, true)
-    } else {
-      callback(new Error('Not allowed by CORS'))
-    }
-  }
-}
+// const corsOptions = {
+//   origin: function (origin, callback) {
+//     console.log('request attempted from ', origin)
+//     if (whitelist.indexOf(origin) !== -1) {
+//       callback(null, true)
+//     } else {
+//       callback(new Error('Not allowed by CORS'))
+//     }
+//   }
+// }
 
 class App {
     //Run configuration methods on the Express instance.
@@ -47,18 +47,18 @@ class App {
         /* This is just to get up and running, and to make sure what we've got is
          * working so far. This function will change when we start to add more
          * API endpoints */
-        this.express.get('/test', cors(corsOptions), (req, res) => {
+        this.express.get('/test', (req, res) => {
           console.log(req)
           res.json({response: 'yo mamma'})
         })
 
-        this.express.get('/list', cors(corsOptions), (req, res) => {
+        this.express.get('/list', (req, res) => {
           Attendee.findAll().then(attendees => {
             res.json({attendees: attendees})
           })
         })
 
-        this.express.post('/attendee', cors(corsOptions), (req, res) => {
+        this.express.post('/attendee', (req, res) => {
           console.log(req.body)
           if ('name' in req.body) {
             Attendee.findOrCreate({