-
Notifications
You must be signed in to change notification settings - Fork 9
Refresh error: "Error: ENOENT" #23
Comments
This seems to be a missing feature of angular-cli. When using webpack-dev-server (which angular-cli wraps), you can use |
A workaround for this is to change your Angular frontend to talk to the Express backend on separate ports. To do this, modify let config: StormpathConfiguration = new StormpathConfiguration();
config.endpointPrefix = 'http://localhost:3000';
@NgModule({
...
providers: [{
provide: StormpathConfiguration, useValue: config
}],
...
})
export class AppModule { } After making this change, you'll also need to enable CORS in express-stormpath.
var cors = require('cors');
...
var app = express();
app.use(cors({
origin: 'http://localhost:4200',
credentials: true
}));
"start": "concurrently --raw \"ng serve\" \"node server/server.js stormpath-api\"", |
Closing because workaround provided. |
I have the same issue with my project https://github.com/ZeMovie/ZeMovie_app and cant apply your fix : |
@Loona61 Instead of this: let config: StormpathConfiguration = new StormpathConfiguration();
config.endpointPrefix = 'http://localhost:3000'; Use something like this: export function stormpathConfig(): StormpathConfiguration {
let spConfig: StormpathConfiguration = new StormpathConfiguration();
spConfig.endpointPrefix = 'http://api.mycompany.com';
spConfig.meUri = '/account';
return spConfig;
}
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, StormpathModule],
bootstrap: [AppComponent],
providers: [{
provide: StormpathConfiguration, useFactory: stormpathConfig
}]
})
export class DemoModule {
} |
already try with :
but still doesnt work. No error, but all page redirect to homepage and I can't logout |
If you're using Client API, this should work. If you're using a server integration, the only one that supports |
look at my project : https://github.com/ZeMovie/ZeMovie_app |
@Loona61 You need to add the proxy configuration to the startup in order for the requests to be proxied to express. See https://github.com/stormpath/stormpath-angular2-express-example/blob/master/package.json#L7 You'll also need to change your import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { StormpathModule } from 'angular-stormpath';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
StormpathModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { } |
?? That why I use your fix form #23 (comment) (using cors and removing proxy configuration) but, thank you so much for your time. |
@Loona61 I'm afraid you'll have to wait for |
@mraible Strange, I'm the only who tried the tutorial on Angular2 ? ^^ Anyway , thx again for your time. |
@Loona61 Yes, it's possible you're the only one that's tried it. 😉 You could use Angular CLI's eject feature. I had to trim
Then you should be able to modify You could also use our Spring Boot support that supports |
@mraible Between you and me, has your example ever worked once? When you wrote the tutorial? Because even the example Git does not work with me. 😉 I will try eject feature. |
No, I don't believe it worked if you refreshed the page. However, you're not supposed to do that in a single page app, especially a tutorial! 😉 When you ship to production, you're not going to use webpack's dev server to serve things up, are you? In my ng-demo project, I use http-server-spa to serve up the app. "start": "http-server-spa public index.html 8080", It also builds on every install: "preinstall": "npm install -g http-server-spa",
"postinstall": "ng build -prod --aot && cp -r dist/* public/." This automates things when deploying to Heroku. |
@mraible :/ I think I missunderstand something. I'm so newbie for now with all of this and too bad in english for speak clearly ^^ I just play with all of this in dev mode, never thinking about production for now. I stop spamming you :) thank you again for your help and fast response. |
The sample project available at https://github.com/stormpath/stormpath-angular2-express-example.git works fine. Restructuring the app to something more realistic introduces a few problems. Restructured project is available at the following repository, with read me explaining the changes (in short: routing, three components routing, dedicated login page).
https://github.com/patricknee/stormpath-angular2-testbed
On the referenced projects "Login" page, refreshing the page with the Chrome refresh button results in the following error:
Error: ENOENT: no such file or directory, stat '/Users/patrick/dev/repos/stormpath-angular2-express-example/index.html'
at Error (native)
The text was updated successfully, but these errors were encountered: