API Plugin Prefix

Hey all, for some reason my prefix isn't applying on the data paths This is my env file:
# API
API_PREFIX=v1/
API_ORIGIN=*
API_PORT=4000
# API
API_PREFIX=v1/
API_ORIGIN=*
API_PORT=4000
This is the line from the ServerOptions:
auth: parseApiAuth(),
prefix: envParseString('API_PREFIX', 'v1/'),
origin: envParseString('API_ORIGIN'),
listenOptions: { port: envParseInteger('API_PORT') }
auth: parseApiAuth(),
prefix: envParseString('API_PREFIX', 'v1/'),
origin: envParseString('API_ORIGIN'),
listenOptions: { port: envParseInteger('API_PORT') }
This is the user route in the routes folder:
export class UserRoute extends Route {
public constructor(context: Route.LoaderContext, options: Route.Options) {
super(context, {
...options,
route: 'hello-world'
});
}

public [methods.GET](_request: ApiRequest, response: ApiResponse) {
response.json({ message: 'Hello World' });
}

public [methods.POST](_request: ApiRequest, response: ApiResponse) {
response.json({ message: 'Hello World' });
}
}
export class UserRoute extends Route {
public constructor(context: Route.LoaderContext, options: Route.Options) {
super(context, {
...options,
route: 'hello-world'
});
}

public [methods.GET](_request: ApiRequest, response: ApiResponse) {
response.json({ message: 'Hello World' });
}

public [methods.POST](_request: ApiRequest, response: ApiResponse) {
response.json({ message: 'Hello World' });
}
}
So this means that it should be accessible on 127.0.0.1:4000/v1/hello-world or localhost:4000/v1/hello-world correct? I'm only getting a response from 127.0.0.1:4000/hello-world and localhost:4000/hello-world I've read through the docs and am probably missing something simple, just been overlooking it I guess or I don't understand enough about the implementation, maybe this doesn't matter unless the environment is set up with to use that route
Solution:
disregard, it seems that it was due to something local, I reinstalled all the node_modules and the prefix worked correctly.
Jump to solution
3 Replies
Favna
Favna3mo ago
@kyra 🩵🩷🤍🩷🩵 do you recall anything about this?
kyra
kyra3mo ago
Uh, I'll have to check
Solution
Baylem
Baylem3mo ago
disregard, it seems that it was due to something local, I reinstalled all the node_modules and the prefix worked correctly.