fix: makes patch work by working around and faking production for yarn dev in api
parent
a2d16800aa
commit
886b101887
|
@ -10,28 +10,36 @@ const withTM = require("next-transpile-modules")([
|
||||||
// use something like withPlugins([withTM], {}) if more plugins added later.
|
// use something like withPlugins([withTM], {}) if more plugins added later.
|
||||||
|
|
||||||
module.exports = withTM({
|
module.exports = withTM({
|
||||||
|
async headers() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
// matching all API routes
|
||||||
|
source: "/api/:path*",
|
||||||
|
headers: [
|
||||||
|
{ key: "Access-Control-Allow-Credentials", value: "true" },
|
||||||
|
{ key: "Access-Control-Allow-Origin", value: "*" },
|
||||||
|
{ key: "Access-Control-Allow-Methods", value: "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
|
||||||
|
{
|
||||||
|
key: "Access-Control-Allow-Headers",
|
||||||
|
value:
|
||||||
|
"X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, Content-Type, api_key, Authorization",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
async rewrites() {
|
async rewrites() {
|
||||||
return {
|
return [
|
||||||
beforeFiles: [
|
// This redirects requests recieved at / the root to the /api/ folder.
|
||||||
// This redirects requests recieved at / the root to the /api/ folder.
|
{
|
||||||
{
|
source: "/:rest*",
|
||||||
source: "/v:version/:rest*",
|
destination: "/api/:rest*",
|
||||||
destination: "/api/v:version/:rest*",
|
},
|
||||||
},
|
// This redirects requests to api/v*/ to /api/ passing version as a query parameter.
|
||||||
// This redirects requests to api/v*/ to /api/ passing version as a query parameter.
|
{
|
||||||
{
|
source: "/api/v:version/:rest*",
|
||||||
source: "/api/v:version/:rest*",
|
destination: "/api/:rest*?version=:version",
|
||||||
destination: "/api/:rest*?version=:version",
|
},
|
||||||
},
|
];
|
||||||
],
|
|
||||||
fallback: [
|
|
||||||
// These rewrites are checked after both pages/public files
|
|
||||||
// and dynamic routes are checked
|
|
||||||
{
|
|
||||||
source: "/:path*",
|
|
||||||
destination: `/api/:path*`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
"author": "Cal.com Inc.",
|
"author": "Cal.com Inc.",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "PORT=3002 next",
|
"dev": "next build && PORT=3002 next start",
|
||||||
"start": "next start",
|
"start": "PORT=3002 next start",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"lint-fix": "next lint --fix && prettier --write .",
|
"lint-fix": "next lint --fix && prettier --write .",
|
||||||
|
|
Loading…
Reference in New Issue