Skip to content

Commit

Permalink
Update Formio NCES endpoint CORS configuration to not take request ho…
Browse files Browse the repository at this point in the history
…st into account when enabling CORS
  • Loading branch information
courtneymyers committed Aug 23, 2023
1 parent 1c3f5f1 commit 08bca20
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions app/server/app/routes/formioNCES.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,8 @@ const { FORMIO_NCES_API_KEY } = process.env;

const router = express.Router();

/**
* Enable CORS for local development
*
* @param {express.Request} req
* @param {express.Response} res
* @param {express.NextFunction} next
*/
function enableLocalhostCORS(req, res, next) {
if (req.get("host") === "localhost:3001") {
cors({ origin: "*" });
}

next();
}

// --- Search the NCES data with the provided NCES ID and return a match
router.get("/:searchText?", enableLocalhostCORS, (req, res) => {
router.get("/:searchText?", cors({ origin: "*" }), (req, res) => {
const { searchText } = req.params;
const apiKey = req.headers["x-api-key"];

Expand Down

0 comments on commit 08bca20

Please sign in to comment.