File tree 2 files changed +19
-46
lines changed
packages/runtime/src/helpers
2 files changed +19
-46
lines changed Original file line number Diff line number Diff line change @@ -145,22 +145,25 @@ export const redirectsForNextRouteWithData = ({
145
145
} ) )
146
146
147
147
export const getApiRewrites = ( basePath : string , apiRoutes : Array < ApiRouteConfig > ) => {
148
- const apiRewrites = apiRoutes . map ( ( apiRoute ) => {
149
- const [ from ] = toNetlifyRoute ( `${ basePath } ${ apiRoute . route } ` )
150
-
151
- // Scheduled functions can't be invoked directly, so we 404 them.
152
- if ( apiRoute . config . type === ApiRouteType . SCHEDULED ) {
153
- return { from, to : '/404.html' , status : 404 }
154
- }
155
- return {
156
- from,
157
- to : `/.netlify/functions/${ getFunctionNameForPage (
158
- apiRoute . route ,
159
- apiRoute . config . type === ApiRouteType . BACKGROUND ,
160
- ) } `,
161
- status : 200 ,
162
- }
163
- } )
148
+ const apiRewrites = apiRoutes
149
+ // Only create custom rewrites for API routes that are background or scheduled functions.
150
+ . filter ( ( apiRoute ) => apiRoute . config . type !== undefined )
151
+ . map ( ( apiRoute ) => {
152
+ const [ from ] = toNetlifyRoute ( `${ basePath } ${ apiRoute . route } ` )
153
+
154
+ // Scheduled functions can't be invoked directly, so we 404 them.
155
+ if ( apiRoute . config . type === ApiRouteType . SCHEDULED ) {
156
+ return { from, to : '/404.html' , status : 404 }
157
+ }
158
+ return {
159
+ from,
160
+ to : `/.netlify/functions/${ getFunctionNameForPage (
161
+ apiRoute . route ,
162
+ apiRoute . config . type === ApiRouteType . BACKGROUND ,
163
+ ) } `,
164
+ status : 200 ,
165
+ }
166
+ } )
164
167
165
168
return [
166
169
...apiRewrites ,
Original file line number Diff line number Diff line change @@ -1095,21 +1095,6 @@ Array [
1095
1095
" status" : 200 ,
1096
1096
" to" : " /.netlify/functions/___netlify-handler" ,
1097
1097
} ,
1098
- Object {
1099
- " from" : " /api/enterPreview" ,
1100
- " status" : 200 ,
1101
- " to" : " /.netlify/functions/_api_enterPreview-handler" ,
1102
- } ,
1103
- Object {
1104
- " from" : " /api/exitPreview" ,
1105
- " status" : 200 ,
1106
- " to" : " /.netlify/functions/_api_exitPreview-handler" ,
1107
- } ,
1108
- Object {
1109
- " from" : " /api/hello" ,
1110
- " status" : 200 ,
1111
- " to" : " /.netlify/functions/_api_hello-handler" ,
1112
- } ,
1113
1098
Object {
1114
1099
" from" : " /api/hello-background" ,
1115
1100
" status" : 200 ,
@@ -1120,21 +1105,6 @@ Array [
1120
1105
" status" : 404 ,
1121
1106
" to" : " /404.html" ,
1122
1107
} ,
1123
- Object {
1124
- " from" : " /api/og" ,
1125
- " status" : 200 ,
1126
- " to" : " /.netlify/functions/_api_og-handler" ,
1127
- } ,
1128
- Object {
1129
- " from" : " /api/shows/:id" ,
1130
- " status" : 200 ,
1131
- " to" : " /.netlify/functions/_api_shows_id-PARAM-handler" ,
1132
- } ,
1133
- Object {
1134
- " from" : " /api/shows/:params/*" ,
1135
- " status" : 200 ,
1136
- " to" : " /.netlify/functions/_api_shows_params-SPLAT-handler" ,
1137
- } ,
1138
1108
Object {
1139
1109
" force" : false ,
1140
1110
" from" : " /broken-image" ,
You can’t perform that action at this time.
0 commit comments