2

Hello I'm using the serve npm package. I am trying to serve static files on a different route. Let's say I have the following directory structure that I'm trying to serve:

  • index.html
  • index.js
  • helpers
    • helper.js

I'm trying to serve it on a specific route using the serve package, but I can't seem to get the rewrite syntax correct. I'm trying to serve it on the custom route. What I have as the config is:

{
  "rewrites": [
    {"source":"custom/**", "destination":""}
  ]
}

Any help would be much appreciated.

thisguy
  • 63
  • 6

2 Answers2

1

Maybe you need export your server and call baseURL

in helper

export const server = {
 baseURL: 'http:localhost:3000'
}

i expect that resolve your problem

Israel Omar
  • 56
  • 1
  • 6
0

I'm confident that empty string will throw serve for a loop.

Try:

{
  "rewrites": [
    {"source":"custom/**", "destination":"/**"}
  ]
}

That assumes your folder structure is in the same folder you told serve to operate on. You would change the destination if your files were in a different folder.

Eg:

$ pwd
/var/web/site

$ ls
old_files/ index.html

$ ls old_files
index.html index.js helpers/

Your config should be:

{
  "rewrites": [
    {"source":"custom/**", "destination":"/old_files/**"}
  ]
}
James Perih
  • 1,360
  • 1
  • 17
  • 19