Hi,
When testing our code locally, it looks like our browser (and Postman) is able to make an OPTIONS call to verify our CORS data.
Our APIs (on Remix, using routes + loaders for routes) has this code
if (request.method === ‘OPTIONS’) {
return new Response(null, {
headers: {
‘Access-Control-Allow-Origin’: ‘’,
‘Access-Control-Allow-Methods’: ‘PUT, POST, GET, DELETE, OPTIONS’,
‘Access-Control-Allow-Headers’: ‘’,
‘Access-Control-Max-Age’: ‘9999999’,
},
});
}
Things are good locally.
However, after deploying on our server, I see this in our fly.io app logs.
ErrorResponse {
status: 405,
statusText: ‘Method Not Allowed’,
internal: true,
data: ‘Error: Invalid request method “OPTIONS”’,
error: Error: Invalid request method “OPTIONS”
at getInternalRouterError (/myapp/node_modules/@remix-run/router/router.ts:3072:5)
at Object.queryRoute (/myapp/node_modules/@remix-run/router/router.ts:2055:13)
at handleResourceRequestRR (/myapp/node_modules/@remix-run/server-runtime/dist/server.js:271:40)
at requestHandler (/myapp/node_modules/@remix-run/server-runtime/dist/server.js:47:24)
at /myapp/node_modules/@sentry/src/utils/instrumentServer.ts:432:1
at bound (node:domain:433:15)
at runBound (node:domain:444:12)
at /myapp/node_modules/@sentry/src/utils/instrumentServer.ts:438:1
at /myapp/node_modules/@remix-run/express/dist/server.js:39:28
at Layer.handle [as handle_request] (/myapp/node_modules/express/lib/router/layer.js:95:5)
Postman returns 500 Internal Server Error
Thoughts on whether this is a config setting? Appreciate your help.