NeahNew/.next/server/app/api/missions/image/[...path]/route.js
2026-01-02 14:32:36 +01:00

1 line
3.2 KiB
JavaScript

(()=>{var e={};e.id=4839,e.ids=[4839],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},47493:(e,t,r)=>{"use strict";r.r(t),r.d(t,{patchFetch:()=>h,routeModule:()=>l,serverHooks:()=>g,workAsyncStorage:()=>d,workUnitAsyncStorage:()=>m});var s={};r.r(s),r.d(s,{GET:()=>c});var n=r(96559),o=r(48088),i=r(37719),a=r(32190),p=r(91043);let u=new p.S3Client({region:"us-east-1",endpoint:"https://dome-api.slm-lab.net",credentials:{accessKeyId:"4aBT4CMb7JIMMyUtp4Pl",secretAccessKey:"HGn39XhCIlqOjmDVzRK9MED2Fci2rYvDDgbLFElg"},forcePathStyle:!0});async function c(e,{params:t}){try{let{path:e}=await t;if(!e||0===e.length)return console.error("No path segments provided"),new a.NextResponse("Path is required",{status:400});let r=e.join("/");console.log("Fetching mission image:",{originalPath:r,segments:e});let s=r.replace(/^missions\//,"");console.log("Full Minio path:",{minioPath:s,bucket:"missions",endpoint:"https://dome-api.slm-lab.net"});let n=new p.GetObjectCommand({Bucket:"missions",Key:s});try{let e=await u.send(n);if(!e.Body)return console.error("File not found in Minio:",{path:r,minioPath:s,bucket:"missions",contentType:e.ContentType}),new a.NextResponse("File not found",{status:404});let t=e.ContentType||"image/png",o=new Headers;return o.set("Content-Type",t),o.set("Cache-Control","public, max-age=31536000"),console.log("Serving image:",{path:r,minioPath:s,contentType:t,contentLength:e.ContentLength,lastModified:e.LastModified,etag:e.ETag}),new a.NextResponse(e.Body,{headers:o})}catch(e){if(console.error("Error fetching file from Minio:",{error:e,path:r,minioPath:s,bucket:"missions",endpoint:"https://dome-api.slm-lab.net",errorType:e instanceof p.NoSuchKey?"NoSuchKey":"Unknown"}),e instanceof p.NoSuchKey)return new a.NextResponse("File not found",{status:404});return new a.NextResponse("Internal Server Error",{status:500})}}catch(e){return console.error("Error in image serving:",{error:e,errorType:e instanceof Error?e.constructor.name:typeof e,message:e instanceof Error?e.message:String(e)}),new a.NextResponse("Internal Server Error",{status:500})}}let l=new n.AppRouteRouteModule({definition:{kind:o.RouteKind.APP_ROUTE,page:"/api/missions/image/[...path]/route",pathname:"/api/missions/image/[...path]",filename:"route",bundlePath:"app/api/missions/image/[...path]/route"},resolvedPagePath:"/Users/alma/Documents/NeahNew/app/api/missions/image/[...path]/route.ts",nextConfigOutput:"",userland:s}),{workAsyncStorage:d,workUnitAsyncStorage:m,serverHooks:g}=l;function h(){return(0,i.patchFetch)({workAsyncStorage:d,workUnitAsyncStorage:m})}},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},78335:()=>{},91043:e=>{"use strict";e.exports=require("@aws-sdk/client-s3")},96487:()=>{}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[4243,580],()=>r(47493));module.exports=s})();