Ok, I will setup a striped down version. For now, here is my folder structure of the project.
.
├── apps
│ ├── api
│ │ ├── project.json
│ │ └── src
│ │ ├── app
│ │ ├── assets
│ │ ├── environments
│ │ ├── main.ts
│ │ └── netlify.toml
│ └── spacez-marketplace-v2
│ ├── netlify.toml
│ └── project.json
├── libs
│ ├── marketplace
│ └── ...
├── package.json
├── nx.json
└── ...
The project.json for the api is as follows:
{
"name": "api",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/api/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/webpack:webpack",
"outputs": [
"{options.outputPath}"
],
"defaultConfiguration": "production",
"options": {
"target": "node",
"compiler": "tsc",
"outputPath": "dist/apps/api",
"main": "apps/api/src/main.ts",
"tsConfig": "apps/api/tsconfig.app.json",
"assets": [
"apps/api/src/assets",
"apps/api/src/netlify.toml",
"apps/api/src/schedule.js",
"apps/api/src/schema"
],
"webpackConfig": "apps/api/webpack.config.js"
},
"configurations": {
"development": {},
"production": {}
}
},
"serve": {
"executor": "@nrwl/js:node",
"defaultConfiguration": "development",
"options": {
"buildTarget": "api:build"
},
"configurations": {
"development": {
"buildTarget": "api:build:development"
},
"production": {
"buildTarget": "api:build:production"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": [
"apps/api/**/*.ts"
]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": [
"{workspaceRoot}/coverage/{projectRoot}"
],
"options": {
"jestConfig": "apps/api/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"tags": []
}
And here is my netlify.toml
[build]
command = "nx run api:build:production"
publish = "./site/"
functions = "../../dist/apps/api"
[functions]
included_files = ["./schema/*"]
[[redirects]]
from = "/*"
to = "/.netlify/functions/main"
status = 200
[[headers]]
for = "/*"
[headers.values]
Access-Control-Allow-Origin = "*"
Content-Type = "application/json"