File tree Expand file tree Collapse file tree
web/src/app/api/v1/chat/completions/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -624,11 +624,17 @@ describe('/api/v1/chat/completions POST endpoint', () => {
624624 } )
625625
626626 it ( 'rejects free-mode requests when location is unknown' , async ( ) => {
627+ // Use a TEST-NET-1 IP (RFC 5737) that geoip-lite cannot resolve, with
628+ // no cf-ipcountry header. This avoids the dev-only localhost bypass
629+ // (which kicks in when there is no cf-ipcountry AND no/loopback IP).
627630 const req = new NextRequest (
628631 'http://localhost:3000/api/v1/chat/completions' ,
629632 {
630633 method : 'POST' ,
631- headers : { Authorization : 'Bearer test-api-key-new-free' } ,
634+ headers : {
635+ Authorization : 'Bearer test-api-key-new-free' ,
636+ 'cf-connecting-ip' : '192.0.2.1' ,
637+ } ,
632638 body : JSON . stringify ( {
633639 model : 'minimax/minimax-m2.7' ,
634640 stream : false ,
@@ -658,7 +664,7 @@ describe('/api/v1/chat/completions POST endpoint', () => {
658664 const body = await response . json ( )
659665 expect ( body . error ) . toBe ( 'free_mode_unavailable' )
660666 expect ( body . countryCode ) . toBe ( 'UNKNOWN' )
661- expect ( body . countryBlockReason ) . toBe ( 'missing_client_ip ' )
667+ expect ( body . countryBlockReason ) . toBe ( 'unresolved_client_ip ' )
662668 } )
663669
664670 it ( 'rejects free-mode requests from anonymized Cloudflare country codes' , async ( ) => {
You can’t perform that action at this time.
0 commit comments