Go buffalo and angular app with packr doesn't work after build
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Description
I have setup buffalo project which serves angular 6 front-end. All my APIs are written in buffalo with their own routes with /api prefix, while front-end routes are written in angular. Buffalo is rendering index.html from dist folder, using packr to pack this folder. The problem is app works fine locally with my dev environment (buffalo dev
). However, it doesn't render front-end on final build (buffalo build
), though APIs are working.
Project structure
Angular repository is in webapp directory, and building it in webapp/dist folder.
Buffalo renders it using packr.
actions > render.go
//webapp distribution folder
var assetsBox = packr.NewBox("../webapp/dist")
func init() {
r = render.New(render.Options{
// HTML layout to be used for all HTML requests:
// HTMLLayout: "application.html",
//webapp distribution folder
TemplatesBox: assetsBox,
AssetsBox: assetsBox,
// Add template helpers here:
Helpers: render.Helpers{},
})
}
actions > app.go
// API routes
api := app.Group(API_PREFIX)
api.Use(Authorize)
// Set the request content type to JSON
api.Use(contenttype.Set("application/json"))
api.POST("/auth/create", AuthCreate)
api.GET("/users", UserList)
api.POST("/users", UserCreate)
api.Middleware.Skip(Authorize, AuthCreate,)
// Front-end routes
app.ServeFiles("/", assetsBox)
app.GET("/", HomeHandler)
app.GET("/{path:.+}", HomeHandler)
actions > home.go
// HomeHandler is a default handler to serve up
// a home page.
func HomeHandler(c buffalo.Context) error {
//webapp entry point
return c.Render(200, r.HTML("index.html"))
}
As I mentioned earlier, index.html file is in webapp/dist folder.
Steps to reproduce
buffalo dev
will render UI on http://127.0.0.1:3000
buffalo build
will be successful with final binary. Even more, this binary runs fine and starting application at 127.0.0.1:3000. However, browser doesn't render UI, it says could not find. Interesting stuff is, you can still evident all angular files such as http://127.0.0.1:3000/vendor.js. Only index.html doesn't render. Remember, APIs are also working.
To debug, I renamed index.html to app.html and build it using buffalo build
. Angular app got initiated, if I manually run http://127.0.0.1:3000/app.html. But I can't go with that as browser refresh will be an issue.
angular go buffalo
add a comment |
Description
I have setup buffalo project which serves angular 6 front-end. All my APIs are written in buffalo with their own routes with /api prefix, while front-end routes are written in angular. Buffalo is rendering index.html from dist folder, using packr to pack this folder. The problem is app works fine locally with my dev environment (buffalo dev
). However, it doesn't render front-end on final build (buffalo build
), though APIs are working.
Project structure
Angular repository is in webapp directory, and building it in webapp/dist folder.
Buffalo renders it using packr.
actions > render.go
//webapp distribution folder
var assetsBox = packr.NewBox("../webapp/dist")
func init() {
r = render.New(render.Options{
// HTML layout to be used for all HTML requests:
// HTMLLayout: "application.html",
//webapp distribution folder
TemplatesBox: assetsBox,
AssetsBox: assetsBox,
// Add template helpers here:
Helpers: render.Helpers{},
})
}
actions > app.go
// API routes
api := app.Group(API_PREFIX)
api.Use(Authorize)
// Set the request content type to JSON
api.Use(contenttype.Set("application/json"))
api.POST("/auth/create", AuthCreate)
api.GET("/users", UserList)
api.POST("/users", UserCreate)
api.Middleware.Skip(Authorize, AuthCreate,)
// Front-end routes
app.ServeFiles("/", assetsBox)
app.GET("/", HomeHandler)
app.GET("/{path:.+}", HomeHandler)
actions > home.go
// HomeHandler is a default handler to serve up
// a home page.
func HomeHandler(c buffalo.Context) error {
//webapp entry point
return c.Render(200, r.HTML("index.html"))
}
As I mentioned earlier, index.html file is in webapp/dist folder.
Steps to reproduce
buffalo dev
will render UI on http://127.0.0.1:3000
buffalo build
will be successful with final binary. Even more, this binary runs fine and starting application at 127.0.0.1:3000. However, browser doesn't render UI, it says could not find. Interesting stuff is, you can still evident all angular files such as http://127.0.0.1:3000/vendor.js. Only index.html doesn't render. Remember, APIs are also working.
To debug, I renamed index.html to app.html and build it using buffalo build
. Angular app got initiated, if I manually run http://127.0.0.1:3000/app.html. But I can't go with that as browser refresh will be an issue.
angular go buffalo
Problem resolved by puttingapp.ServeFiles("/", assetsBox)
to the bottom. Also, removedapp.GET("/{path:.+}", HomeHandler)
.
– Nijesh Hirpara
Jan 8 at 6:44
add a comment |
Description
I have setup buffalo project which serves angular 6 front-end. All my APIs are written in buffalo with their own routes with /api prefix, while front-end routes are written in angular. Buffalo is rendering index.html from dist folder, using packr to pack this folder. The problem is app works fine locally with my dev environment (buffalo dev
). However, it doesn't render front-end on final build (buffalo build
), though APIs are working.
Project structure
Angular repository is in webapp directory, and building it in webapp/dist folder.
Buffalo renders it using packr.
actions > render.go
//webapp distribution folder
var assetsBox = packr.NewBox("../webapp/dist")
func init() {
r = render.New(render.Options{
// HTML layout to be used for all HTML requests:
// HTMLLayout: "application.html",
//webapp distribution folder
TemplatesBox: assetsBox,
AssetsBox: assetsBox,
// Add template helpers here:
Helpers: render.Helpers{},
})
}
actions > app.go
// API routes
api := app.Group(API_PREFIX)
api.Use(Authorize)
// Set the request content type to JSON
api.Use(contenttype.Set("application/json"))
api.POST("/auth/create", AuthCreate)
api.GET("/users", UserList)
api.POST("/users", UserCreate)
api.Middleware.Skip(Authorize, AuthCreate,)
// Front-end routes
app.ServeFiles("/", assetsBox)
app.GET("/", HomeHandler)
app.GET("/{path:.+}", HomeHandler)
actions > home.go
// HomeHandler is a default handler to serve up
// a home page.
func HomeHandler(c buffalo.Context) error {
//webapp entry point
return c.Render(200, r.HTML("index.html"))
}
As I mentioned earlier, index.html file is in webapp/dist folder.
Steps to reproduce
buffalo dev
will render UI on http://127.0.0.1:3000
buffalo build
will be successful with final binary. Even more, this binary runs fine and starting application at 127.0.0.1:3000. However, browser doesn't render UI, it says could not find. Interesting stuff is, you can still evident all angular files such as http://127.0.0.1:3000/vendor.js. Only index.html doesn't render. Remember, APIs are also working.
To debug, I renamed index.html to app.html and build it using buffalo build
. Angular app got initiated, if I manually run http://127.0.0.1:3000/app.html. But I can't go with that as browser refresh will be an issue.
angular go buffalo
Description
I have setup buffalo project which serves angular 6 front-end. All my APIs are written in buffalo with their own routes with /api prefix, while front-end routes are written in angular. Buffalo is rendering index.html from dist folder, using packr to pack this folder. The problem is app works fine locally with my dev environment (buffalo dev
). However, it doesn't render front-end on final build (buffalo build
), though APIs are working.
Project structure
Angular repository is in webapp directory, and building it in webapp/dist folder.
Buffalo renders it using packr.
actions > render.go
//webapp distribution folder
var assetsBox = packr.NewBox("../webapp/dist")
func init() {
r = render.New(render.Options{
// HTML layout to be used for all HTML requests:
// HTMLLayout: "application.html",
//webapp distribution folder
TemplatesBox: assetsBox,
AssetsBox: assetsBox,
// Add template helpers here:
Helpers: render.Helpers{},
})
}
actions > app.go
// API routes
api := app.Group(API_PREFIX)
api.Use(Authorize)
// Set the request content type to JSON
api.Use(contenttype.Set("application/json"))
api.POST("/auth/create", AuthCreate)
api.GET("/users", UserList)
api.POST("/users", UserCreate)
api.Middleware.Skip(Authorize, AuthCreate,)
// Front-end routes
app.ServeFiles("/", assetsBox)
app.GET("/", HomeHandler)
app.GET("/{path:.+}", HomeHandler)
actions > home.go
// HomeHandler is a default handler to serve up
// a home page.
func HomeHandler(c buffalo.Context) error {
//webapp entry point
return c.Render(200, r.HTML("index.html"))
}
As I mentioned earlier, index.html file is in webapp/dist folder.
Steps to reproduce
buffalo dev
will render UI on http://127.0.0.1:3000
buffalo build
will be successful with final binary. Even more, this binary runs fine and starting application at 127.0.0.1:3000. However, browser doesn't render UI, it says could not find. Interesting stuff is, you can still evident all angular files such as http://127.0.0.1:3000/vendor.js. Only index.html doesn't render. Remember, APIs are also working.
To debug, I renamed index.html to app.html and build it using buffalo build
. Angular app got initiated, if I manually run http://127.0.0.1:3000/app.html. But I can't go with that as browser refresh will be an issue.
angular go buffalo
angular go buffalo
asked Jan 4 at 6:33
Nijesh HirparaNijesh Hirpara
5431613
5431613
Problem resolved by puttingapp.ServeFiles("/", assetsBox)
to the bottom. Also, removedapp.GET("/{path:.+}", HomeHandler)
.
– Nijesh Hirpara
Jan 8 at 6:44
add a comment |
Problem resolved by puttingapp.ServeFiles("/", assetsBox)
to the bottom. Also, removedapp.GET("/{path:.+}", HomeHandler)
.
– Nijesh Hirpara
Jan 8 at 6:44
Problem resolved by putting
app.ServeFiles("/", assetsBox)
to the bottom. Also, removed app.GET("/{path:.+}", HomeHandler)
.– Nijesh Hirpara
Jan 8 at 6:44
Problem resolved by putting
app.ServeFiles("/", assetsBox)
to the bottom. Also, removed app.GET("/{path:.+}", HomeHandler)
.– Nijesh Hirpara
Jan 8 at 6:44
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54034077%2fgo-buffalo-and-angular-app-with-packr-doesnt-work-after-build%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54034077%2fgo-buffalo-and-angular-app-with-packr-doesnt-work-after-build%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Problem resolved by putting
app.ServeFiles("/", assetsBox)
to the bottom. Also, removedapp.GET("/{path:.+}", HomeHandler)
.– Nijesh Hirpara
Jan 8 at 6:44