Hoggie
Hoggie

Reputation: 194

Is there a way to setup 2 frontends in phoenix app?

In the project I have phoenix web app which serves its own frontend (webpack 5, served on "/")

  plug Plug.Static,
    at: "/",
    from: :myapp_web,
    gzip: false,
    only: ~w(css fonts images js robots.txt favicon.ico)

I want to add another frontend (which would be served on /app (this frontend uses API I built). I decided to try adding another frontend as static app, so I configured nuxt to build static files:

export default {
  ssr: false,
  target: 'static'

in nuxt.config.js and configure endpoint properly:

 plug Plug.Static,
    at: "/app",
    from: "myapp-app/dist",
    gzip: false

this allows to work (but only partialy):

I want to found a way to fix that problem - by changing paths in Endpoint (when visiting localhost:4000/posts render file from localhost:4000/posts/index.html), however, I don't know how should I do that. I am thinking if this is the right approach and if not how should I proceed?

Upvotes: 0

Views: 123

Answers (1)

kissu
kissu

Reputation: 46676

Did you tried the following structure for your Nuxt app?

pages/
-- posts/
---- index.vue

Otherwise, we could look for a redirect but I'm curious why /index may not be generated here. Do you have all your routes when you yarn generate?

Upvotes: 1

Related Questions