File tree 2 files changed +15
-1
lines changed
packages/runtime/src/helpers
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,14 @@ describe('API routes', () => {
6
6
} )
7
7
} )
8
8
9
+ describe ( 'Dynamic API routes' , ( ) => {
10
+ it ( 'are bundled correctly' , ( ) => {
11
+ cy . request ( '/api/shows/1' ) . then ( ( response ) => {
12
+ expect ( response . status ) . to . equal ( 200 )
13
+ } )
14
+ } )
15
+ } )
16
+
9
17
describe ( 'Extended API routes' , ( ) => {
10
18
it ( 'returns HTTP 202 Accepted for background route' , ( ) => {
11
19
cy . request ( '/api/hello-background' ) . then ( ( response ) => {
Original file line number Diff line number Diff line change @@ -96,6 +96,12 @@ export const hasManuallyAddedModule = ({
96
96
)
97
97
/* eslint-enable camelcase */
98
98
99
+ /**
100
+ * Transforms `/api/shows/[id].js` into `/api/shows/*id*.js`,
101
+ * so that the file `[id].js` is matched correctly.
102
+ */
103
+ const escapeGlob = ( path : string ) => path . replace ( / \[ / g, '*' ) . replace ( / ] / g, '*' )
104
+
99
105
export const configureHandlerFunctions = async ( {
100
106
netlifyConfig,
101
107
publish,
@@ -173,7 +179,7 @@ export const configureHandlerFunctions = async ({
173
179
netlifyConfig . functions [ functionName ] ||= { included_files : [ ] }
174
180
netlifyConfig . functions [ functionName ] . node_bundler = 'none'
175
181
netlifyConfig . functions [ functionName ] . included_files ||= [ ]
176
- netlifyConfig . functions [ functionName ] . included_files . push ( ...includedFiles )
182
+ netlifyConfig . functions [ functionName ] . included_files . push ( ...includedFiles . map ( escapeGlob ) )
177
183
}
178
184
} else {
179
185
configureFunction ( '_api_*' )
You can’t perform that action at this time.
0 commit comments