generated from nhcarrigan/template
feat: client and server logic to manage announcements #3
@ -4,6 +4,7 @@
|
|||||||
* @author Naomi Carrigan
|
* @author Naomi Carrigan
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { routesWithoutCors } from "../config/routesWithoutCors.js";
|
||||||
import type { onRequestHookHandler } from "fastify";
|
import type { onRequestHookHandler } from "fastify";
|
||||||
|
|
||||||
const isValidOrigin = (origin: string | undefined): boolean => {
|
const isValidOrigin = (origin: string | undefined): boolean => {
|
||||||
@ -27,7 +28,7 @@ const isValidOrigin = (origin: string | undefined): boolean => {
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises -- For reasons I cannot comprehend, Fastify seems to require us to return a request?
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises -- For reasons I cannot comprehend, Fastify seems to require us to return a request?
|
||||||
export const corsHook: onRequestHookHandler = async(request, response) => {
|
export const corsHook: onRequestHookHandler = async(request, response) => {
|
||||||
if (!request.url.startsWith("/submit")) {
|
if (routesWithoutCors.includes(request.url)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (!isValidOrigin(request.headers.origin)) {
|
if (!isValidOrigin(request.headers.origin)) {
|
||||||
|
Reference in New Issue
Block a user