Public Folder for each Domain #6
Replies: 2 comments 3 replies
-
|
@inspiretk, thanks for sharing! Let me think of a way to include that inside the config file without extra configurations or scripts. Of course, I'm open to PRs 🙂 |
Beta Was this translation helpful? Give feedback.
-
|
There are issues with <Image> tag from next/link. Next link's src will be / goes to root of public folder. Eg /veggies/filename. However <img> will work as normal /filename. So Next link has access to other sites, whereas image tag dont. So for me, I will just hardcode a variable to take the site's public folder when using Next Image tag. eg
Micheleriva - thanks for your youtube video. Helped me set it up easily. Without that video, I wouldn't be able to follow the documentation. Videos for me, just helps setting it up much easier with documentation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I got working using public folder for each domain. If someone else has their better solution please share.
In main index.js file where express server is running, I did this inside main(). So put between the code const server = express() and server.get.
So in root, create folder public. Then create subfolders for each of your domain. Create subfolder englishsetterlovers, and veggies.
The domainMap: You put your domains in there. I'm sure you can create a file for this and import that in, that way you dont hardcode it into your index.js file.
When on production using real domain name, you can replace : with . This will use your domain name without the extension. I did the : because of my localhost being domain name + :3000 with no extension. eg http://veggies:3000.
let hostName = hostName2.split(':')
replace with
let hostName = hostName2.split('.')
I did this way because example using of favicon. I got this answer from https://stackoverflow.com/questions/60025303/set-express-static-directory-dynamically
Beta Was this translation helpful? Give feedback.
All reactions