Commit 64fc6c6 1 parent 55b5afd commit 64fc6c6 Copy full SHA for 64fc6c6
File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { FetchError } from 'ofetch' ;
2
2
import useExtendedNitroApp from '~/server/composables/useExtendedNitroApp' ;
3
3
4
+ const ALLOWED_URL_REGEX = [
5
+ / a s s e m b l i e s \/ d \/ [ 0 - 9 a - z ] + \/ w \/ [ 0 - 9 a - z ] + \/ e \/ [ 0 - 9 a - z ] + \/ b o m \? i n d e n t e d = f a l s e / ,
6
+ / d o c u m e n t s \/ [ 0 - 9 a - z ] + / ,
7
+ / p a r t s \/ d \/ [ 0 - 9 a - z ] + \/ [ v w ] \/ [ 0 - 9 a - z ] + \/ e \/ [ 0 - 9 a - z ] + \/ p a r t i d \/ [ a - z A - Z ] { 3 } \/ b o u n d i n g b o x e s \? c o n f i g u r a t i o n = .* / ,
8
+ ] ;
9
+
4
10
export default defineEventHandler ( async ( event ) => {
5
11
const { onshape } = useExtendedNitroApp ( ) ;
6
12
const url = event . node . req . originalUrl ! . replace ( '/api/onshape/' , '' ) ;
7
13
14
+ if ( ! ALLOWED_URL_REGEX . find ( ( regex ) => regex . test ( url ) ) ) {
15
+ setResponseStatus ( event , 400 ) ;
16
+ return {
17
+ message : 'URL is not allowed' ,
18
+ url,
19
+ } ;
20
+ }
21
+
8
22
try {
9
23
return await onshape . fetch ( url ) ;
10
24
} catch ( err ) {
You can’t perform that action at this time.
0 commit comments