/api/version returning 404
Answered
Caspian Nightworth posted this in #help-forum
I am using the recommended App Router and have in my app directory a folder called api and in it I have a file called version.ts.
The contents of that file is:
Trying to hit that route from http://localhost:3000/api/version I am returned with a 404. I cannot figure out why this is. I have restarted my application to see if it was just not being picked up, but that does not seem to be the case. Any help regarding this is greatly appreciated.
The contents of that file is:
import { NextRequest, NextResponse } from 'next/server'; // Import from 'next/server'
import getConfig from 'next/config';
const { publicRuntimeConfig } = getConfig();
export async function GET(request: NextRequest) { // Use 'GET'
console.log('API Route Triggered:', publicRuntimeConfig.version);
return NextResponse.json({ version: publicRuntimeConfig.version });
}Trying to hit that route from http://localhost:3000/api/version I am returned with a 404. I cannot figure out why this is. I have restarted my application to see if it was just not being picked up, but that does not seem to be the case. Any help regarding this is greatly appreciated.
6 Replies
still learning all this about NextJs
does that mean i can have multiple exports in there, one fore a GET, one for POST, etc...?
Yes
Answer
thank you